fix logging implementation
Signed-off-by: kim (grufwub) <grufwub@gmail.com>
This commit is contained in:
parent
5957b7e588
commit
3b00f6ec11
@ -20,7 +20,7 @@ func setupLogger(output string) loggerInterface {
|
||||
case "null":
|
||||
return &nullLogger{}
|
||||
default:
|
||||
fd, err := os.OpenFile(output, os.O_CREATE|os.O_APPEND, 0600)
|
||||
fd, err := os.OpenFile(output, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
|
||||
if err != nil {
|
||||
log.Fatalf(logOutputErrStr, output, err.Error())
|
||||
}
|
||||
@ -55,22 +55,22 @@ func (l *stdLogger) Fatal(fmt string, args ...interface{}) {
|
||||
|
||||
// logger implements LoggerInterface to log to output using underlying log.Logger
|
||||
type logger struct {
|
||||
logger *log.Logger
|
||||
lg *log.Logger
|
||||
}
|
||||
|
||||
// Info logs to log.Logger with info level prefix
|
||||
func (l *logger) Info(fmt string, args ...interface{}) {
|
||||
l.logger.Printf("I :: "+fmt, args...)
|
||||
l.lg.Printf("I :: "+fmt, args...)
|
||||
}
|
||||
|
||||
// Error logs to log.Logger with error level prefix
|
||||
func (l *logger) Error(fmt string, args ...interface{}) {
|
||||
l.logger.Printf("E :: "+fmt, args...)
|
||||
l.lg.Printf("E :: "+fmt, args...)
|
||||
}
|
||||
|
||||
// Fatal logs to log.Logger with fatal prefix and terminates program
|
||||
func (l *logger) Fatal(fmt string, args ...interface{}) {
|
||||
l.logger.Fatalf("F :: "+fmt, args...)
|
||||
l.lg.Fatalf("F :: "+fmt, args...)
|
||||
}
|
||||
|
||||
// nullLogger implements LoggerInterface to do absolutely fuck-all
|
||||
|
@ -64,7 +64,7 @@ func ParseFlagsAndSetup(proto string, errorMessageFunc func(ErrorCode) string) {
|
||||
|
||||
// Setup loggers
|
||||
SystemLog = setupLogger(*sysLog)
|
||||
if sysLog == accLog {
|
||||
if *sysLog == *accLog {
|
||||
AccessLog = SystemLog
|
||||
} else {
|
||||
AccessLog = setupLogger(*accLog)
|
||||
|
Loading…
Reference in New Issue
Block a user