2020-07-19 19:32:22 +02:00
|
|
|
// Copyright 2015 The Xorm Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2022-07-16 11:43:41 +02:00
|
|
|
//go:build !windows && !nacl && !plan9
|
2020-07-19 19:32:22 +02:00
|
|
|
// +build !windows,!nacl,!plan9
|
|
|
|
|
|
|
|
package log
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log/syslog"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ Logger = &SyslogLogger{}
|
|
|
|
|
|
|
|
// SyslogLogger will be depricated
|
|
|
|
type SyslogLogger struct {
|
|
|
|
w *syslog.Writer
|
|
|
|
showSQL bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewSyslogLogger implements Logger
|
|
|
|
func NewSyslogLogger(w *syslog.Writer) *SyslogLogger {
|
|
|
|
return &SyslogLogger{w: w}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Debug log content as Debug
|
|
|
|
func (s *SyslogLogger) Debug(v ...interface{}) {
|
2022-07-16 11:43:41 +02:00
|
|
|
_ = s.w.Debug(fmt.Sprint(v...))
|
2020-07-19 19:32:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Debugf log content as Debug and format
|
|
|
|
func (s *SyslogLogger) Debugf(format string, v ...interface{}) {
|
2022-07-16 11:43:41 +02:00
|
|
|
_ = s.w.Debug(fmt.Sprintf(format, v...))
|
2020-07-19 19:32:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Error log content as Error
|
|
|
|
func (s *SyslogLogger) Error(v ...interface{}) {
|
2022-07-16 11:43:41 +02:00
|
|
|
_ = s.w.Err(fmt.Sprint(v...))
|
2020-07-19 19:32:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Errorf log content as Errorf and format
|
|
|
|
func (s *SyslogLogger) Errorf(format string, v ...interface{}) {
|
2022-07-16 11:43:41 +02:00
|
|
|
_ = s.w.Err(fmt.Sprintf(format, v...))
|
2020-07-19 19:32:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Info log content as Info
|
|
|
|
func (s *SyslogLogger) Info(v ...interface{}) {
|
2022-07-16 11:43:41 +02:00
|
|
|
_ = s.w.Info(fmt.Sprint(v...))
|
2020-07-19 19:32:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Infof log content as Infof and format
|
|
|
|
func (s *SyslogLogger) Infof(format string, v ...interface{}) {
|
2022-07-16 11:43:41 +02:00
|
|
|
_ = s.w.Info(fmt.Sprintf(format, v...))
|
2020-07-19 19:32:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Warn log content as Warn
|
|
|
|
func (s *SyslogLogger) Warn(v ...interface{}) {
|
2022-07-16 11:43:41 +02:00
|
|
|
_ = s.w.Warning(fmt.Sprint(v...))
|
2020-07-19 19:32:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Warnf log content as Warnf and format
|
|
|
|
func (s *SyslogLogger) Warnf(format string, v ...interface{}) {
|
2022-07-16 11:43:41 +02:00
|
|
|
_ = s.w.Warning(fmt.Sprintf(format, v...))
|
2020-07-19 19:32:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Level shows log level
|
|
|
|
func (s *SyslogLogger) Level() LogLevel {
|
|
|
|
return LOG_UNKNOWN
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetLevel always return error, as current log/syslog package doesn't allow to set priority level after syslog.Writer created
|
|
|
|
func (s *SyslogLogger) SetLevel(l LogLevel) {}
|
|
|
|
|
|
|
|
// ShowSQL set if logging SQL
|
|
|
|
func (s *SyslogLogger) ShowSQL(show ...bool) {
|
|
|
|
if len(show) == 0 {
|
|
|
|
s.showSQL = true
|
|
|
|
return
|
|
|
|
}
|
|
|
|
s.showSQL = show[0]
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsShowSQL if logging SQL
|
|
|
|
func (s *SyslogLogger) IsShowSQL() bool {
|
|
|
|
return s.showSQL
|
|
|
|
}
|