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