schnutibox/pkg/sselog/sselog.go

21 lines
409 B
Go
Raw Normal View History

2021-03-30 19:59:26 +02:00
// package sselog is work in progress to implement a writer that sends its logs
// to a http server side event.
package sselog
type SSELog struct {
LogChan chan []byte
Receivers []chan string
}
func (l SSELog) Write(p []byte) (n int, err error) {
wCount := 0
// Send log message to all receiver channels.
for _, i := range l.Receivers {
i <- string(p)
wCount = +len(p)
}
return wCount, nil
}