mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-20 14:41:28 +01:00
bug fix: different call depth
This commit is contained in:
parent
9004e4ef82
commit
c22a642b55
@ -27,6 +27,8 @@ import (
|
|||||||
var logger = New(os.Stdout, NewTextFormatter(), WarningLevel)
|
var logger = New(os.Stdout, NewTextFormatter(), WarningLevel)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
logger.callDepth = 3
|
||||||
|
|
||||||
// TODO add item in configuaration file
|
// TODO add item in configuaration file
|
||||||
lvl := os.Getenv("LOG_LEVEL")
|
lvl := os.Getenv("LOG_LEVEL")
|
||||||
if len(lvl) == 0 {
|
if len(lvl) == 0 {
|
||||||
@ -49,6 +51,7 @@ type Logger struct {
|
|||||||
out io.Writer
|
out io.Writer
|
||||||
fmtter Formatter
|
fmtter Formatter
|
||||||
lvl Level
|
lvl Level
|
||||||
|
callDepth int
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,6 +61,7 @@ func New(out io.Writer, fmtter Formatter, lvl Level) *Logger {
|
|||||||
out: out,
|
out: out,
|
||||||
fmtter: fmtter,
|
fmtter: fmtter,
|
||||||
lvl: lvl,
|
lvl: lvl,
|
||||||
|
callDepth: 2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +121,7 @@ func (l *Logger) output(record *Record) (err error) {
|
|||||||
// Debug ...
|
// Debug ...
|
||||||
func (l *Logger) Debug(v ...interface{}) {
|
func (l *Logger) Debug(v ...interface{}) {
|
||||||
if l.lvl <= DebugLevel {
|
if l.lvl <= DebugLevel {
|
||||||
line := line(2)
|
line := line(l.callDepth)
|
||||||
record := NewRecord(time.Now(), fmt.Sprint(v...), line, DebugLevel)
|
record := NewRecord(time.Now(), fmt.Sprint(v...), line, DebugLevel)
|
||||||
l.output(record)
|
l.output(record)
|
||||||
}
|
}
|
||||||
@ -126,7 +130,7 @@ func (l *Logger) Debug(v ...interface{}) {
|
|||||||
// Debugf ...
|
// Debugf ...
|
||||||
func (l *Logger) Debugf(format string, v ...interface{}) {
|
func (l *Logger) Debugf(format string, v ...interface{}) {
|
||||||
if l.lvl <= DebugLevel {
|
if l.lvl <= DebugLevel {
|
||||||
line := line(2)
|
line := line(l.callDepth)
|
||||||
record := NewRecord(time.Now(), fmt.Sprintf(format, v...), line, DebugLevel)
|
record := NewRecord(time.Now(), fmt.Sprintf(format, v...), line, DebugLevel)
|
||||||
l.output(record)
|
l.output(record)
|
||||||
}
|
}
|
||||||
@ -167,7 +171,7 @@ func (l *Logger) Warningf(format string, v ...interface{}) {
|
|||||||
// Error ...
|
// Error ...
|
||||||
func (l *Logger) Error(v ...interface{}) {
|
func (l *Logger) Error(v ...interface{}) {
|
||||||
if l.lvl <= ErrorLevel {
|
if l.lvl <= ErrorLevel {
|
||||||
line := line(2)
|
line := line(l.callDepth)
|
||||||
record := NewRecord(time.Now(), fmt.Sprint(v...), line, ErrorLevel)
|
record := NewRecord(time.Now(), fmt.Sprint(v...), line, ErrorLevel)
|
||||||
l.output(record)
|
l.output(record)
|
||||||
}
|
}
|
||||||
@ -176,7 +180,7 @@ func (l *Logger) Error(v ...interface{}) {
|
|||||||
// Errorf ...
|
// Errorf ...
|
||||||
func (l *Logger) Errorf(format string, v ...interface{}) {
|
func (l *Logger) Errorf(format string, v ...interface{}) {
|
||||||
if l.lvl <= ErrorLevel {
|
if l.lvl <= ErrorLevel {
|
||||||
line := line(2)
|
line := line(l.callDepth)
|
||||||
record := NewRecord(time.Now(), fmt.Sprintf(format, v...), line, ErrorLevel)
|
record := NewRecord(time.Now(), fmt.Sprintf(format, v...), line, ErrorLevel)
|
||||||
l.output(record)
|
l.output(record)
|
||||||
}
|
}
|
||||||
@ -185,7 +189,7 @@ func (l *Logger) Errorf(format string, v ...interface{}) {
|
|||||||
// Fatal ...
|
// Fatal ...
|
||||||
func (l *Logger) Fatal(v ...interface{}) {
|
func (l *Logger) Fatal(v ...interface{}) {
|
||||||
if l.lvl <= FatalLevel {
|
if l.lvl <= FatalLevel {
|
||||||
line := line(2)
|
line := line(l.callDepth)
|
||||||
record := NewRecord(time.Now(), fmt.Sprint(v...), line, FatalLevel)
|
record := NewRecord(time.Now(), fmt.Sprint(v...), line, FatalLevel)
|
||||||
l.output(record)
|
l.output(record)
|
||||||
}
|
}
|
||||||
@ -195,7 +199,7 @@ func (l *Logger) Fatal(v ...interface{}) {
|
|||||||
// Fatalf ...
|
// Fatalf ...
|
||||||
func (l *Logger) Fatalf(format string, v ...interface{}) {
|
func (l *Logger) Fatalf(format string, v ...interface{}) {
|
||||||
if l.lvl <= FatalLevel {
|
if l.lvl <= FatalLevel {
|
||||||
line := line(2)
|
line := line(l.callDepth)
|
||||||
record := NewRecord(time.Now(), fmt.Sprintf(format, v...), line, FatalLevel)
|
record := NewRecord(time.Now(), fmt.Sprintf(format, v...), line, FatalLevel)
|
||||||
l.output(record)
|
l.output(record)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user