diff --git a/utils/logger.go b/utils/logger.go new file mode 100644 index 000000000..de92d3c5c --- /dev/null +++ b/utils/logger.go @@ -0,0 +1,32 @@ +package utils + +import ( + "log" + "os" +) + +type Logger struct { + infoLogger *log.Logger + errorLogger *log.Logger + debugLogger *log.Logger +} + +func NewLogger() *Logger { + return &Logger{ + infoLogger: log.New(os.Stdout, "INFO: ", log.Ldate|log.Ltime|log.Lshortfile), + errorLogger: log.New(os.Stderr, "ERROR: ", log.Ldate|log.Ltime|log.Lshortfile), + debugLogger: log.New(os.Stdout, "DEBUG: ", log.Ldate|log.Ltime|log.Lshortfile), + } +} + +func (l *Logger) Info(format string, v ...interface{}) { + l.infoLogger.Printf(format, v...) +} + +func (l *Logger) Error(format string, v ...interface{}) { + l.errorLogger.Printf(format, v...) +} + +func (l *Logger) Debug(format string, v ...interface{}) { + l.debugLogger.Printf(format, v...) +}