Skip to content

Commit

Permalink
Create a logger util
Browse files Browse the repository at this point in the history
  • Loading branch information
MahtabBukhari committed Dec 18, 2024
1 parent b6bf153 commit 66b8956
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions utils/logger.go
Original file line number Diff line number Diff line change
@@ -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...)
}

0 comments on commit 66b8956

Please sign in to comment.