Documentation
¶
Index ¶
- Constants
- Variables
- func ConvertLevel2String(level LogLevel) string
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func GetCaller(skip int) *runtime.Frame
- func GetFileName(frame *runtime.Frame) string
- func GetPackageName(f string) string
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func Initial(configFile string) error
- func Initialized() bool
- func RemoveEnterAndSpace(str string) string
- func StartRolling()
- func StopRolling()
- func Trace(args ...interface{})
- func Tracef(format string, args ...interface{})
- func Variable(varchar, pattern, str string) (string, string)
- func VariableReplaceByConfig(str string) string
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- type Config
- type ConsoleLogger
- func (this *ConsoleLogger) CheckRollingSize()
- func (this *ConsoleLogger) Debug(args ...interface{})
- func (this *ConsoleLogger) Debugf(format string, args ...interface{})
- func (this *ConsoleLogger) Error(args ...interface{})
- func (this *ConsoleLogger) Errorf(format string, args ...interface{})
- func (this *ConsoleLogger) FatalWithExit(exit bool, args ...interface{})
- func (this *ConsoleLogger) FatalfWithExit(exit bool, format string, args ...interface{})
- func (this *ConsoleLogger) Info(args ...interface{})
- func (this *ConsoleLogger) Infof(format string, args ...interface{})
- func (this *ConsoleLogger) Trace(args ...interface{})
- func (this *ConsoleLogger) Tracef(format string, args ...interface{})
- func (this *ConsoleLogger) Warn(args ...interface{})
- func (this *ConsoleLogger) Warnf(format string, args ...interface{})
- type FileLogger
- type Filter
- type Format
- type Formatter
- type JSONFormatter
- type Level
- type LogLevel
- type Logger
- type LoggerWriter
- func (this *LoggerWriter) AfterSQL(context xormlog.LogContext)
- func (this *LoggerWriter) BeforeSQL(context xormlog.LogContext)
- func (this *LoggerWriter) Debug(args ...interface{})
- func (this *LoggerWriter) Debugf(format string, args ...interface{})
- func (this *LoggerWriter) Error(args ...interface{})
- func (this *LoggerWriter) Errorf(format string, args ...interface{})
- func (this *LoggerWriter) Fatal(v ...interface{})
- func (this *LoggerWriter) FatalWithExit(exit bool, args ...interface{})
- func (this *LoggerWriter) Fatalf(format string, v ...interface{})
- func (this *LoggerWriter) FatalfWithExit(exit bool, format string, args ...interface{})
- func (this *LoggerWriter) Fatalln(v ...interface{})
- func (this *LoggerWriter) Info(args ...interface{})
- func (this *LoggerWriter) Infof(format string, args ...interface{})
- func (this *LoggerWriter) IsShowSQL() bool
- func (this *LoggerWriter) Level() xormlog.LogLevel
- func (this *LoggerWriter) NewLogger(w io.Writer)
- func (this *LoggerWriter) Output(calldepth int, s string) error
- func (this *LoggerWriter) Panic(v ...interface{})
- func (this *LoggerWriter) Panicf(format string, v ...interface{})
- func (this *LoggerWriter) Panicln(v ...interface{})
- func (this *LoggerWriter) Prefix() string
- func (this *LoggerWriter) Print(v ...interface{})
- func (this *LoggerWriter) Printf(format string, v ...interface{})
- func (this *LoggerWriter) Println(v ...interface{})
- func (this *LoggerWriter) SetDenyLevel(level LogLevel)
- func (this *LoggerWriter) SetFormatter(formatter Formatter)
- func (this *LoggerWriter) SetLevel(l xormlog.LogLevel)
- func (this *LoggerWriter) SetPrefix(prefix string)
- func (this *LoggerWriter) SetSkipCallerDepth(skipCallerDepth int)
- func (this *LoggerWriter) SetWriter(w io.Writer)
- func (this *LoggerWriter) ShowSQL(show ...bool)
- func (this *LoggerWriter) Trace(args ...interface{})
- func (this *LoggerWriter) Tracef(format string, args ...interface{})
- func (this *LoggerWriter) Warn(args ...interface{})
- func (this *LoggerWriter) Warnf(format string, args ...interface{})
- func (this *LoggerWriter) Write(level LogLevel, args ...interface{}) error
- type Property
- type Rolling
- type TextFormatter
- type Writer
Constants ¶
const ( ALL = 0 TRACE = 1 DEBUG = 2 INFO = 3 WARN = 4 ERROR = 5 FATAL = 6 OFF = 7 DefaultLogTimeFormat = "2006/01/02 15:04:05.000000" )
ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL < OFF
Variables ¶
var ( DefaultWriter = os.Stdout FileWithoutPKG = false )
var (
DefaultFormat = "%{Prefix} - %{Time:yyyy-mm-dd HH:MM:SS.ms} - %{Level:5} - %{File}:%{Line:3} - %{Message}"
)
Functions ¶
func ConvertLevel2String ¶
func GetFileName ¶
func GetPackageName ¶
Get the package name by runtime.Frame.Function
func Initialized ¶
func Initialized() bool
func RemoveEnterAndSpace ¶
func StartRolling ¶
func StartRolling()
func StopRolling ¶
func StopRolling()
func VariableReplaceByConfig ¶
Replace the variable define in properties
Types ¶
type Config ¶
type Config struct {
XMLName xml.Name `xml:"Configuration"`
RollingInterval int `xml:"rollingInterval,attr"`
Properties []Property `xml:"Properties>Property"`
Loggers []Logger `xml:"Loggers>Logger"`
DefaultFilter Filter `xml:"Filters>DefaultFilter>Filter"`
PackageFilters []Filter `xml:"Filters>PackageFilter>Filter"`
}
type ConsoleLogger ¶
type ConsoleLogger struct {
*LoggerWriter
// contains filtered or unexported fields
}
func DefaultConsoleLogger ¶
func DefaultConsoleLogger() *ConsoleLogger
func NewConsoleLogger ¶
func NewConsoleLogger(level LogLevel) *ConsoleLogger
func (*ConsoleLogger) CheckRollingSize ¶
func (this *ConsoleLogger) CheckRollingSize()
Do nothing with implement interface Writer
func (*ConsoleLogger) Debug ¶
func (this *ConsoleLogger) Debug(args ...interface{})
func (*ConsoleLogger) Debugf ¶
func (this *ConsoleLogger) Debugf(format string, args ...interface{})
func (*ConsoleLogger) Error ¶
func (this *ConsoleLogger) Error(args ...interface{})
func (*ConsoleLogger) Errorf ¶
func (this *ConsoleLogger) Errorf(format string, args ...interface{})
func (*ConsoleLogger) FatalWithExit ¶
func (this *ConsoleLogger) FatalWithExit(exit bool, args ...interface{})
func (*ConsoleLogger) FatalfWithExit ¶
func (this *ConsoleLogger) FatalfWithExit(exit bool, format string, args ...interface{})
func (*ConsoleLogger) Info ¶
func (this *ConsoleLogger) Info(args ...interface{})
func (*ConsoleLogger) Infof ¶
func (this *ConsoleLogger) Infof(format string, args ...interface{})
func (*ConsoleLogger) Trace ¶
func (this *ConsoleLogger) Trace(args ...interface{})
func (*ConsoleLogger) Tracef ¶
func (this *ConsoleLogger) Tracef(format string, args ...interface{})
ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL < OFF
func (*ConsoleLogger) Warn ¶
func (this *ConsoleLogger) Warn(args ...interface{})
func (*ConsoleLogger) Warnf ¶
func (this *ConsoleLogger) Warnf(format string, args ...interface{})
type FileLogger ¶
type FileLogger struct {
*LoggerWriter
// contains filtered or unexported fields
}
func NewFileLogger ¶
func NewFileLogger(level LogLevel, logFile string) (*FileLogger, error)
func NewFileLoggerWithConfig ¶
func NewFileLoggerWithConfig(v Logger) (*FileLogger, error)
func (*FileLogger) CheckRollingSize ¶
func (this *FileLogger) CheckRollingSize()
func (*FileLogger) RollingFile ¶
func (this *FileLogger) RollingFile()
Rolling a new file to write logger
type JSONFormatter ¶
type JSONFormatter struct {
Indent bool
}
func NewJSONFormatter ¶
func NewJSONFormatter() *JSONFormatter
func (*JSONFormatter) Message ¶
func (this *JSONFormatter) Message(data map[string]interface{}, args ...interface{}) string
type LogLevel ¶
type LogLevel int
Logger level
func ConvertString2Level ¶
Convert string level name to level
type Logger ¶
type Logger struct {
XMLName xml.Name `xml:"Logger"`
Name string `xml:"name,attr"`
Target string `xml:"target,attr"`
FileName string `xml:"fileName,attr"`
FilePattern string `xml:"filePattern,attr"`
Compress string `xml:"compress,attr"`
Format Format `xml:"Format"`
Level Level `xml:"Level"`
Rolling Rolling `xml:"Rolling"`
}
type LoggerWriter ¶
func NewLoggerWriter ¶
func NewLoggerWriter(w io.Writer, level LogLevel) *LoggerWriter
func (*LoggerWriter) AfterSQL ¶
func (this *LoggerWriter) AfterSQL(context xormlog.LogContext)
func (*LoggerWriter) BeforeSQL ¶
func (this *LoggerWriter) BeforeSQL(context xormlog.LogContext)
func (*LoggerWriter) Debug ¶
func (this *LoggerWriter) Debug(args ...interface{})
func (*LoggerWriter) Debugf ¶
func (this *LoggerWriter) Debugf(format string, args ...interface{})
func (*LoggerWriter) Error ¶
func (this *LoggerWriter) Error(args ...interface{})
func (*LoggerWriter) Errorf ¶
func (this *LoggerWriter) Errorf(format string, args ...interface{})
func (*LoggerWriter) Fatal ¶
func (this *LoggerWriter) Fatal(v ...interface{})
Fatal is equivalent to l.Print() followed by a call to os.Exit(1).
func (*LoggerWriter) FatalWithExit ¶
func (this *LoggerWriter) FatalWithExit(exit bool, args ...interface{})
func (*LoggerWriter) Fatalf ¶
func (this *LoggerWriter) Fatalf(format string, v ...interface{})
Fatalf is equivalent to l.Printf() followed by a call to os.Exit(1).
func (*LoggerWriter) FatalfWithExit ¶
func (this *LoggerWriter) FatalfWithExit(exit bool, format string, args ...interface{})
func (*LoggerWriter) Fatalln ¶
func (this *LoggerWriter) Fatalln(v ...interface{})
Fatalln is equivalent to l.Println() followed by a call to os.Exit(1).
func (*LoggerWriter) Info ¶
func (this *LoggerWriter) Info(args ...interface{})
func (*LoggerWriter) Infof ¶
func (this *LoggerWriter) Infof(format string, args ...interface{})
func (*LoggerWriter) IsShowSQL ¶
func (this *LoggerWriter) IsShowSQL() bool
func (*LoggerWriter) Level ¶
func (this *LoggerWriter) Level() xormlog.LogLevel
func (*LoggerWriter) NewLogger ¶
func (this *LoggerWriter) NewLogger(w io.Writer)
func (*LoggerWriter) Output ¶
func (this *LoggerWriter) Output(calldepth int, s string) error
Rewrite log.Logger function
func (*LoggerWriter) Panic ¶
func (this *LoggerWriter) Panic(v ...interface{})
Panic is equivalent to l.Print() followed by a call to panic().
func (*LoggerWriter) Panicf ¶
func (this *LoggerWriter) Panicf(format string, v ...interface{})
Panicf is equivalent to l.Printf() followed by a call to panic().
func (*LoggerWriter) Panicln ¶
func (this *LoggerWriter) Panicln(v ...interface{})
Panicln is equivalent to l.Println() followed by a call to panic().
func (*LoggerWriter) Prefix ¶
func (this *LoggerWriter) Prefix() string
Prefix returns the output prefix for the logger.
func (*LoggerWriter) Print ¶
func (this *LoggerWriter) Print(v ...interface{})
Print calls this.Output to print to the logger. Arguments are handled in the manner of fmt.Print.
func (*LoggerWriter) Printf ¶
func (this *LoggerWriter) Printf(format string, v ...interface{})
Printf calls this.Output to print to the logger. Arguments are handled in the manner of fmt.Printf.
func (*LoggerWriter) Println ¶
func (this *LoggerWriter) Println(v ...interface{})
Println calls this.Output to print to the logger. Arguments are handled in the manner of fmt.Println.
func (*LoggerWriter) SetDenyLevel ¶
func (this *LoggerWriter) SetDenyLevel(level LogLevel)
func (*LoggerWriter) SetFormatter ¶
func (this *LoggerWriter) SetFormatter(formatter Formatter)
func (*LoggerWriter) SetLevel ¶
func (this *LoggerWriter) SetLevel(l xormlog.LogLevel)
func (*LoggerWriter) SetPrefix ¶
func (this *LoggerWriter) SetPrefix(prefix string)
SetPrefix sets the output prefix for the logger.
func (*LoggerWriter) SetSkipCallerDepth ¶
func (this *LoggerWriter) SetSkipCallerDepth(skipCallerDepth int)
func (*LoggerWriter) SetWriter ¶
func (this *LoggerWriter) SetWriter(w io.Writer)
func (*LoggerWriter) ShowSQL ¶
func (this *LoggerWriter) ShowSQL(show ...bool)
func (*LoggerWriter) Trace ¶
func (this *LoggerWriter) Trace(args ...interface{})
ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL < OFF
func (*LoggerWriter) Tracef ¶
func (this *LoggerWriter) Tracef(format string, args ...interface{})
Implement Writer
func (*LoggerWriter) Warn ¶
func (this *LoggerWriter) Warn(args ...interface{})
func (*LoggerWriter) Warnf ¶
func (this *LoggerWriter) Warnf(format string, args ...interface{})
func (*LoggerWriter) Write ¶
func (this *LoggerWriter) Write(level LogLevel, args ...interface{}) error
type TextFormatter ¶
type TextFormatter struct {
Format string
}
func NewTextFormatter ¶
func NewTextFormatter() *TextFormatter
func NewTextFormatterWithFormat ¶
func NewTextFormatterWithFormat(format string) *TextFormatter
func (*TextFormatter) Message ¶
func (this *TextFormatter) Message(data map[string]interface{}, args ...interface{}) string
func (*TextFormatter) SetFormat ¶
func (this *TextFormatter) SetFormat(format string)
type Writer ¶
type Writer interface {
Tracef(format string, args ...interface{})
Debugf(format string, args ...interface{})
Infof(format string, args ...interface{})
Warnf(format string, args ...interface{})
Errorf(format string, args ...interface{})
FatalfWithExit(exit bool, format string, args ...interface{})
Trace(args ...interface{})
Debug(args ...interface{})
Info(args ...interface{})
Warn(args ...interface{})
Error(args ...interface{})
FatalWithExit(exit bool, args ...interface{})
CheckRollingSize()
BeforeSQL(context xormlog.LogContext) // only invoked when IsShowSQL is true
AfterSQL(context xormlog.LogContext) // only invoked when IsShowSQL is true
Level() xormlog.LogLevel
SetLevel(l xormlog.LogLevel)
ShowSQL(show ...bool)
IsShowSQL() bool
}
logger writer interface