mirror of
https://github.com/hibiken/asynq.git
synced 2024-12-26 07:42:17 +08:00
36 lines
674 B
Go
36 lines
674 B
Go
|
package asynq
|
||
|
|
||
|
import (
|
||
|
"io"
|
||
|
"log"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
|
// global logger used in asynq package.
|
||
|
var logger = newLogger(os.Stderr)
|
||
|
|
||
|
func newLogger(out io.Writer) *asynqLogger {
|
||
|
return &asynqLogger{
|
||
|
log.New(out, "", log.Ldate|log.Ltime|log.Lmicroseconds|log.LUTC),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
type asynqLogger struct {
|
||
|
*log.Logger
|
||
|
}
|
||
|
|
||
|
func (l *asynqLogger) info(format string, args ...interface{}) {
|
||
|
format = "INFO: " + format
|
||
|
l.Printf(format, args...)
|
||
|
}
|
||
|
|
||
|
func (l *asynqLogger) warn(format string, args ...interface{}) {
|
||
|
format = "WARN: " + format
|
||
|
l.Printf(format, args...)
|
||
|
}
|
||
|
|
||
|
func (l *asynqLogger) error(format string, args ...interface{}) {
|
||
|
format = "ERROR: " + format
|
||
|
l.Printf(format, args...)
|
||
|
}
|