logger
parent
da98f62438
commit
7054b98d69
|
@ -45,6 +45,7 @@ func (receiver internalLogger) Debugf(format string, a ...interface{}) {
|
|||
buffer.WriteString("[debug] ")
|
||||
}
|
||||
|
||||
buffer.WriteString(receiver.prefix)
|
||||
buffer.WriteString(format)
|
||||
|
||||
switch receiver.style {
|
||||
|
|
|
@ -40,6 +40,7 @@ func (receiver internalLogger) Errorf(format string, a ...interface{}) error {
|
|||
buffer.WriteString("[ERROR] ")
|
||||
}
|
||||
|
||||
buffer.WriteString(receiver.prefix)
|
||||
buffer.WriteString(format)
|
||||
|
||||
switch receiver.style {
|
||||
|
|
|
@ -41,6 +41,7 @@ func (receiver internalLogger) Fatalf(format string, a ...interface{}) {
|
|||
buffer.WriteString("[PANIC] ")
|
||||
}
|
||||
|
||||
buffer.WriteString(receiver.prefix)
|
||||
buffer.WriteString(format)
|
||||
|
||||
switch receiver.style {
|
||||
|
|
|
@ -45,6 +45,7 @@ func (receiver internalLogger) Highlightf(format string, a ...interface{}) {
|
|||
buffer.WriteString("[HIGHLIGHT] ")
|
||||
}
|
||||
|
||||
buffer.WriteString(receiver.prefix)
|
||||
buffer.WriteString(format)
|
||||
|
||||
switch receiver.style {
|
||||
|
|
|
@ -45,6 +45,7 @@ func (receiver internalLogger) Informf(format string, a ...interface{}) {
|
|||
buffer.WriteString("[inform] ")
|
||||
}
|
||||
|
||||
buffer.WriteString(receiver.prefix)
|
||||
buffer.WriteString(format)
|
||||
|
||||
switch receiver.style {
|
||||
|
|
|
@ -40,6 +40,7 @@ func (receiver internalLogger) Panicf(format string, a ...interface{}) {
|
|||
buffer.WriteString("[PANIC] ")
|
||||
}
|
||||
|
||||
buffer.WriteString(receiver.prefix)
|
||||
buffer.WriteString(format)
|
||||
|
||||
switch receiver.style {
|
||||
|
|
|
@ -101,14 +101,14 @@ func TestLoggerPrefix_inform(t *testing.T) {
|
|||
log.Debug("hello DEBUG")
|
||||
log.Trace("hello TRACE")
|
||||
|
||||
const expected = "[PANIC] hello PANIC" + "\n" +
|
||||
const expected = "[PANIC] one: two: three: hello PANIC" + "\n" +
|
||||
"RECOVER:hello PANIC" + "\n" +
|
||||
"[inform] hello INFORM" + "\n" +
|
||||
"[HIGHLIGHT] hello HIGHLIGHT" + "\n" +
|
||||
"[ERROR] hello ERROR" + "\n" +
|
||||
"[warn] hello WARN" + "\n" +
|
||||
"[debug] hello DEBUG" + "\n" +
|
||||
"[trace] 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"
|
||||
|
||||
if actual := buffer.String(); expected != actual {
|
||||
t.Error("The actual logs is not what was expected.")
|
||||
|
|
|
@ -45,6 +45,7 @@ func (receiver internalLogger) Tracef(format string, a ...interface{}) {
|
|||
buffer.WriteString("[trace] ")
|
||||
}
|
||||
|
||||
buffer.WriteString(receiver.prefix)
|
||||
buffer.WriteString(format)
|
||||
|
||||
switch receiver.style {
|
||||
|
|
|
@ -45,6 +45,7 @@ func (receiver internalLogger) Warnf(format string, a ...interface{}) {
|
|||
buffer.WriteString("[warn] ")
|
||||
}
|
||||
|
||||
buffer.WriteString(receiver.prefix)
|
||||
buffer.WriteString(format)
|
||||
|
||||
switch receiver.style {
|
||||
|
|
Loading…
Reference in New Issue