You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
2.0 KiB
88 lines
2.0 KiB
8 years ago
|
// 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.
|
||
|
|
||
|
// +build !windows,!nacl,!plan9
|
||
|
|
||
5 years ago
|
package log
|
||
8 years ago
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"log/syslog"
|
||
|
)
|
||
|
|
||
5 years ago
|
var _ Logger = &SyslogLogger{}
|
||
8 years ago
|
|
||
|
// SyslogLogger will be depricated
|
||
|
type SyslogLogger struct {
|
||
|
w *syslog.Writer
|
||
|
showSQL bool
|
||
|
}
|
||
|
|
||
5 years ago
|
// NewSyslogLogger implements Logger
|
||
8 years ago
|
func NewSyslogLogger(w *syslog.Writer) *SyslogLogger {
|
||
|
return &SyslogLogger{w: w}
|
||
|
}
|
||
|
|
||
8 years ago
|
// Debug log content as Debug
|
||
8 years ago
|
func (s *SyslogLogger) Debug(v ...interface{}) {
|
||
|
s.w.Debug(fmt.Sprint(v...))
|
||
|
}
|
||
|
|
||
8 years ago
|
// Debugf log content as Debug and format
|
||
8 years ago
|
func (s *SyslogLogger) Debugf(format string, v ...interface{}) {
|
||
|
s.w.Debug(fmt.Sprintf(format, v...))
|
||
|
}
|
||
|
|
||
8 years ago
|
// Error log content as Error
|
||
8 years ago
|
func (s *SyslogLogger) Error(v ...interface{}) {
|
||
|
s.w.Err(fmt.Sprint(v...))
|
||
|
}
|
||
|
|
||
8 years ago
|
// Errorf log content as Errorf and format
|
||
8 years ago
|
func (s *SyslogLogger) Errorf(format string, v ...interface{}) {
|
||
|
s.w.Err(fmt.Sprintf(format, v...))
|
||
|
}
|
||
|
|
||
8 years ago
|
// Info log content as Info
|
||
8 years ago
|
func (s *SyslogLogger) Info(v ...interface{}) {
|
||
|
s.w.Info(fmt.Sprint(v...))
|
||
|
}
|
||
|
|
||
8 years ago
|
// Infof log content as Infof and format
|
||
8 years ago
|
func (s *SyslogLogger) Infof(format string, v ...interface{}) {
|
||
|
s.w.Info(fmt.Sprintf(format, v...))
|
||
|
}
|
||
|
|
||
8 years ago
|
// Warn log content as Warn
|
||
8 years ago
|
func (s *SyslogLogger) Warn(v ...interface{}) {
|
||
|
s.w.Warning(fmt.Sprint(v...))
|
||
|
}
|
||
|
|
||
8 years ago
|
// Warnf log content as Warnf and format
|
||
8 years ago
|
func (s *SyslogLogger) Warnf(format string, v ...interface{}) {
|
||
|
s.w.Warning(fmt.Sprintf(format, v...))
|
||
|
}
|
||
|
|
||
8 years ago
|
// Level shows log level
|
||
5 years ago
|
func (s *SyslogLogger) Level() LogLevel {
|
||
|
return LOG_UNKNOWN
|
||
8 years ago
|
}
|
||
|
|
||
|
// SetLevel always return error, as current log/syslog package doesn't allow to set priority level after syslog.Writer created
|
||
5 years ago
|
func (s *SyslogLogger) SetLevel(l LogLevel) {}
|
||
8 years ago
|
|
||
8 years ago
|
// ShowSQL set if logging SQL
|
||
8 years ago
|
func (s *SyslogLogger) ShowSQL(show ...bool) {
|
||
|
if len(show) == 0 {
|
||
|
s.showSQL = true
|
||
|
return
|
||
|
}
|
||
|
s.showSQL = show[0]
|
||
|
}
|
||
|
|
||
8 years ago
|
// IsShowSQL if logging SQL
|
||
8 years ago
|
func (s *SyslogLogger) IsShowSQL() bool {
|
||
|
return s.showSQL
|
||
|
}
|