File tree 1 file changed +20
-5
lines changed
1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import (
19
19
"encoding/json"
20
20
"fmt"
21
21
"html"
22
+ "io"
22
23
"os"
23
24
"runtime"
24
25
"runtime/debug"
@@ -256,7 +257,7 @@ func (h *hub) checkCmd(m []byte) {
256
257
}
257
258
}()
258
259
} else if strings .HasPrefix (sl , "log" ) {
259
- go logAction (sl )
260
+ go h . logAction (sl )
260
261
} else if strings .HasPrefix (sl , "restart" ) {
261
262
log .Println ("Received restart from the daemon. Why? Boh" )
262
263
// TODO enable them
@@ -276,12 +277,26 @@ func (h *hub) checkCmd(m []byte) {
276
277
}
277
278
}
278
279
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 ) {
280
290
if strings .HasPrefix (sl , "log on" ) {
281
291
* 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 )
285
300
} else if strings .HasPrefix (sl , "log off" ) {
286
301
* logDump = "off"
287
302
log .SetOutput (os .Stderr )
You can’t perform that action at this time.
0 commit comments