mirror of
https://github.com/hibiken/asynq.git
synced 2025-10-04 17:42:01 +08:00
Allow custom logger to be used in Background
This commit is contained in:
@@ -8,6 +8,7 @@ package log
|
||||
import (
|
||||
"io"
|
||||
stdlog "log"
|
||||
"os"
|
||||
)
|
||||
|
||||
func NewLogger(out io.Writer) *Logger {
|
||||
@@ -20,6 +21,11 @@ type Logger struct {
|
||||
*stdlog.Logger
|
||||
}
|
||||
|
||||
func (l *Logger) Debug(format string, args ...interface{}) {
|
||||
format = "DEBUG: " + format
|
||||
l.Printf(format, args...)
|
||||
}
|
||||
|
||||
func (l *Logger) Info(format string, args ...interface{}) {
|
||||
format = "INFO: " + format
|
||||
l.Printf(format, args...)
|
||||
@@ -34,3 +40,9 @@ func (l *Logger) Error(format string, args ...interface{}) {
|
||||
format = "ERROR: " + format
|
||||
l.Printf(format, args...)
|
||||
}
|
||||
|
||||
func (l *Logger) Fatal(format string, args ...interface{}) {
|
||||
format = "FATAL: " + format
|
||||
l.Printf(format, args...)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
Reference in New Issue
Block a user