File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -282,20 +282,21 @@ func (h *hub) checkCmd(m []byte) {
282282 }
283283}
284284
285- type logWriter struct {
286- onWrite func ([]byte )
285+ // ChanWriter is a simple io.Writer that sends data to a channel.
286+ type ChanWriter struct {
287+ Ch chan <- []byte
288+ }
289+
290+ func (u * ChanWriter ) Write (p []byte ) (n int , err error ) {
291+ u .Ch <- p
292+ return len (p ), nil
287293}
288294
289295func (h * hub ) logAction (sl string ) {
290296 if strings .HasPrefix (sl , "log on" ) {
291297 * logDump = "on"
292298
293- logWriter := logWriter {}
294- logWriter .onWrite = func (p []byte ) {
295- h .broadcastSys <- p
296- }
297-
298- multiWriter := io .MultiWriter (& logWriter , os .Stderr )
299+ multiWriter := io .MultiWriter (& ChanWriter {Ch : h .broadcastSys }, os .Stderr )
299300 log .SetOutput (multiWriter )
300301 } else if strings .HasPrefix (sl , "log off" ) {
301302 * logDump = "off"
You can’t perform that action at this time.
0 commit comments