diff --git a/main.go b/main.go index cc62d3e..dd5f267 100644 --- a/main.go +++ b/main.go @@ -14,15 +14,18 @@ const ( Trace ) +type LogConfig struct { + Name string + Level int +} type Logger struct { - name string - level int + LogConfig } -func (l *Logger) log(level int, msg string) { +func (l *Logger) log(Level int, msg string) { now := time.Now() - if level <= l.level { - fmt.Println(now.Format("2006-01-02 15:04:05"), " ", l.name, ": ", msg) + if Level <= l.Level { + fmt.Println(now.Format("2006-01-02 15:04:05"), " ", l.Name, ": ", msg) } } @@ -45,6 +48,6 @@ func (l *Logger) Debug(msg string) { func (l *Logger) Trace(msg string) { l.log(Trace, msg) } -func GetLogger(name string) Logger { - return Logger{name, 0} +func GetLogger(logConfig LogConfig) Logger { + return Logger{logConfig} }