github.com/binbinly/pkg@v0.0.11-0.20240321014439-f4fbf666eb0f/logger/logger.go (about) 1 package logger 2 3 var logger = NewLogger() 4 5 // Logger is a generic logging interface. 6 type Logger interface { 7 // Init initializes options 8 Init(options ...Option) error 9 // Fields set fields to always be logged 10 Fields(fields map[string]any) Logger 11 // Log writes a log entry 12 Log(level string, v ...any) 13 // Logf writes a formatted log entry 14 Logf(level string, format string, v ...any) 15 } 16 17 func Init(opts ...Option) error { 18 return logger.Init(opts...) 19 } 20 21 func Fields(fields map[string]any) Logger { 22 return logger.Fields(fields) 23 } 24 25 func Log(level string, v ...any) { 26 logger.Log(level, v...) 27 } 28 29 func Logf(level string, format string, v ...any) { 30 logger.Logf(level, format, v...) 31 }