File tree Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import (
1919 "encoding/json"
2020 "fmt"
2121 "html"
22+ "io"
2223 "os"
2324 "runtime"
2425 "runtime/debug"
@@ -256,7 +257,7 @@ func (h *hub) checkCmd(m []byte) {
256257 }
257258 }()
258259 } else if strings .HasPrefix (sl , "log" ) {
259- go logAction (sl )
260+ go h . logAction (sl )
260261 } else if strings .HasPrefix (sl , "restart" ) {
261262 log .Println ("Received restart from the daemon. Why? Boh" )
262263 // TODO enable them
@@ -276,12 +277,26 @@ func (h *hub) checkCmd(m []byte) {
276277 }
277278}
278279
279- func logAction (sl string ) {
280+ type logWriter struct {
281+ onWrite func ([]byte )
282+ }
283+
284+ func (u * logWriter ) Write (p []byte ) (n int , err error ) {
285+ u .onWrite (p )
286+ return len (p ), nil
287+ }
288+
289+ func (h * hub ) logAction (sl string ) {
280290 if strings .HasPrefix (sl , "log on" ) {
281291 * logDump = "on"
282- // FIXME: pass the loggerSw in the constructor and enable again the log e
283- // multiWriter := io.MultiWriter(&loggerWs, os.Stderr)
284- // log.SetOutput(multiWriter)
292+
293+ logWriter := logWriter {}
294+ logWriter .onWrite = func (p []byte ) {
295+ h .broadcastSys <- p
296+ }
297+
298+ multiWriter := io .MultiWriter (& logWriter , os .Stderr )
299+ log .SetOutput (multiWriter )
285300 } else if strings .HasPrefix (sl , "log off" ) {
286301 * logDump = "off"
287302 log .SetOutput (os .Stderr )
You can’t perform that action at this time.
0 commit comments