2
0
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:
Ken Hibino
2020-03-12 07:31:10 -07:00
parent d664d68fa4
commit 0bc6eba021
8 changed files with 90 additions and 19 deletions

View File

@@ -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)
}