logger
parent
7054b98d69
commit
73a72074c0
|
@ -17,7 +17,7 @@ func (receiver internalLogger) Prefix(newprefix ...string) Logger {
|
||||||
prefix := buffer.String()
|
prefix := buffer.String()
|
||||||
|
|
||||||
var logger internalLogger = receiver
|
var logger internalLogger = receiver
|
||||||
logger.prefix += prefix
|
logger.prefix = prefix
|
||||||
|
|
||||||
return &logger
|
return &logger
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,14 +101,20 @@ func TestLoggerPrefix_inform(t *testing.T) {
|
||||||
log.Debug("hello DEBUG")
|
log.Debug("hello DEBUG")
|
||||||
log.Trace("hello TRACE")
|
log.Trace("hello TRACE")
|
||||||
|
|
||||||
const expected = "[PANIC] one: two: three: hello PANIC" + "\n" +
|
|
||||||
"RECOVER:hello PANIC" + "\n" +
|
log = log.Prefix("four")
|
||||||
"[inform] one: two: three: hello INFORM" + "\n" +
|
log.Highlight("new prefix FOUR")
|
||||||
"[HIGHLIGHT] one: two: three: hello HIGHLIGHT" + "\n" +
|
|
||||||
"[ERROR] one: two: three: hello ERROR" + "\n" +
|
|
||||||
"[warn] one: two: three: hello WARN" + "\n" +
|
const expected = "[PANIC] one: two: three: hello PANIC" + "\n" +
|
||||||
"[debug] one: two: three: hello DEBUG" + "\n" +
|
"RECOVER:hello PANIC" + "\n" +
|
||||||
"[trace] one: two: three: hello TRACE" + "\n"
|
"[inform] one: two: three: hello INFORM" + "\n" +
|
||||||
|
"[HIGHLIGHT] one: two: three: hello HIGHLIGHT" + "\n" +
|
||||||
|
"[ERROR] one: two: three: hello ERROR" + "\n" +
|
||||||
|
"[warn] one: two: three: hello WARN" + "\n" +
|
||||||
|
"[debug] one: two: three: hello DEBUG" + "\n" +
|
||||||
|
"[trace] one: two: three: hello TRACE" + "\n" +
|
||||||
|
"[HIGHLIGHT] one: two: three: four: new prefix FOUR" + "\n"
|
||||||
|
|
||||||
if actual := buffer.String(); expected != actual {
|
if actual := buffer.String(); expected != actual {
|
||||||
t.Error("The actual logs is not what was expected.")
|
t.Error("The actual logs is not what was expected.")
|
||||||
|
|
Loading…
Reference in New Issue