Skip to content

Commit 10a3b27

Browse files
authored
Log to stderr (#122)
Signed-off-by: Sam Willcocks <[email protected]>
1 parent 77870d7 commit 10a3b27

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

log/log.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func NewDefaultLogger() *MiniLogger {
104104
tagEnter: DEFAULT_ENTER_TAG,
105105
tagExit: DEFAULT_EXIT_TAG,
106106
tagColor: color.New(color.FgMagenta),
107-
outputFile: os.Stdout,
107+
outputFile: os.Stderr,
108108
maxStrLength: 64,
109109
}
110110

@@ -361,7 +361,7 @@ func (log MiniLogger) dumpInterface(lvl Level, tag string, value interface{}, sk
361361
}
362362

363363
// TODO: use a general output writer (set to stdout, stderr, or file stream)
364-
fmt.Println(sb.String())
364+
fmt.Fprintln(log.outputFile, sb.String())
365365
} else {
366366
os.Stderr.WriteString("Error: Unable to retrieve call stack. Exiting...")
367367
os.Exit(-2)
@@ -370,7 +370,7 @@ func (log MiniLogger) dumpInterface(lvl Level, tag string, value interface{}, sk
370370
}
371371

372372
func (log MiniLogger) DumpString(value string) {
373-
fmt.Print(value)
373+
fmt.Fprint(log.outputFile, value)
374374
}
375375

376376
func (log MiniLogger) DumpStruct(structName string, field interface{}) error {
@@ -389,7 +389,7 @@ func (log MiniLogger) DumpStruct(structName string, field interface{}) error {
389389
}
390390

391391
// TODO: print to output stream
392-
fmt.Println(sb.String())
392+
fmt.Fprintln(log.outputFile, sb.String())
393393

394394
return nil
395395
}
@@ -398,8 +398,8 @@ func (log MiniLogger) DumpArgs() {
398398
args := os.Args
399399
for i, a := range args {
400400
// TODO: print to output stream
401-
fmt.Print(log.indentRunes)
402-
fmt.Printf("os.Arg[%d]: '%v'\n", i, a)
401+
fmt.Fprint(log.outputFile, log.indentRunes)
402+
fmt.Fprintf(log.outputFile, "os.Arg[%d]: '%v'\n", i, a)
403403
}
404404
}
405405

@@ -409,13 +409,13 @@ func (log MiniLogger) DumpSeparator(sep byte, repeat int) (string, error) {
409409
for i := 0; i < repeat; i++ {
410410
sb.WriteByte(sep)
411411
}
412-
fmt.Println(sb.String())
412+
fmt.Fprintln(log.outputFile, sb.String())
413413
return sb.String(), nil
414414
} else {
415415
return "", errors.New("invalid repeat length (>80)")
416416
}
417417
}
418418

419419
func (log *MiniLogger) DumpStackTrace() {
420-
fmt.Println(string(debug.Stack()))
420+
fmt.Fprintln(log.outputFile, string(debug.Stack()))
421421
}

0 commit comments

Comments
 (0)