log

package
Version: v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2021 License: BSD-3-Clause Imports: 5 Imported by: 76

Documentation

Index

Constants

View Source
const (
	DEFAULT_LOG_PREFIX = "[xorm]"
	DEFAULT_LOG_FLAG   = log.Ldate | log.Lmicroseconds
	DEFAULT_LOG_LEVEL  = LOG_DEBUG
)

default log options

Variables

View Source
var (
	SessionIDKey      = "__xorm_session_id"
	SessionKey        = "__xorm_session_key"
	SessionShowSQLKey = "__xorm_show_sql"
)

enumerate all the context keys

Functions

This section is empty.

Types

type ContextLogger

type ContextLogger interface {
	SQLLogger

	Debugf(format string, v ...interface{})
	Errorf(format string, v ...interface{})
	Infof(format string, v ...interface{})
	Warnf(format string, v ...interface{})

	Level() LogLevel
	SetLevel(l LogLevel)

	ShowSQL(show ...bool)
	IsShowSQL() bool
}

ContextLogger represents a logger interface with context

func NewLoggerAdapter

func NewLoggerAdapter(logger Logger) ContextLogger

NewLoggerAdapter creates an adapter for old xorm logger interface

type DiscardLogger

type DiscardLogger struct{}

DiscardLogger don't log implementation for ILogger

func (DiscardLogger) Debug

func (DiscardLogger) Debug(v ...interface{})

Debug empty implementation

func (DiscardLogger) Debugf

func (DiscardLogger) Debugf(format string, v ...interface{})

Debugf empty implementation

func (DiscardLogger) Error

func (DiscardLogger) Error(v ...interface{})

Error empty implementation

func (DiscardLogger) Errorf

func (DiscardLogger) Errorf(format string, v ...interface{})

Errorf empty implementation

func (DiscardLogger) Info

func (DiscardLogger) Info(v ...interface{})

Info empty implementation

func (DiscardLogger) Infof

func (DiscardLogger) Infof(format string, v ...interface{})

Infof empty implementation

func (DiscardLogger) IsShowSQL

func (DiscardLogger) IsShowSQL() bool

IsShowSQL empty implementation

func (DiscardLogger) Level

func (DiscardLogger) Level() LogLevel

Level empty implementation

func (DiscardLogger) SetLevel

func (DiscardLogger) SetLevel(l LogLevel)

SetLevel empty implementation

func (DiscardLogger) ShowSQL

func (DiscardLogger) ShowSQL(show ...bool)

ShowSQL empty implementation

func (DiscardLogger) Warn

func (DiscardLogger) Warn(v ...interface{})

Warn empty implementation

func (DiscardLogger) Warnf

func (DiscardLogger) Warnf(format string, v ...interface{})

Warnf empty implementation

type LogContext

type LogContext contexts.ContextHook

LogContext represents a log context

type LogLevel

type LogLevel int

LogLevel defines a log level

const (
	// !nashtsai! following level also match syslog.Priority value
	LOG_DEBUG LogLevel = iota
	LOG_INFO
	LOG_WARNING
	LOG_ERR
	LOG_OFF
	LOG_UNKNOWN
)

enumerate all LogLevels

type Logger

type Logger interface {
	Debug(v ...interface{})
	Debugf(format string, v ...interface{})
	Error(v ...interface{})
	Errorf(format string, v ...interface{})
	Info(v ...interface{})
	Infof(format string, v ...interface{})
	Warn(v ...interface{})
	Warnf(format string, v ...interface{})

	Level() LogLevel
	SetLevel(l LogLevel)

	ShowSQL(show ...bool)
	IsShowSQL() bool
}

Logger is a logger interface

type LoggerAdapter

type LoggerAdapter struct {
	// contains filtered or unexported fields
}

LoggerAdapter wraps a Logger interface as LoggerContext interface

func (*LoggerAdapter) AfterSQL

func (l *LoggerAdapter) AfterSQL(ctx LogContext)

AfterSQL implements ContextLogger

func (*LoggerAdapter) BeforeSQL

func (l *LoggerAdapter) BeforeSQL(ctx LogContext)

BeforeSQL implements ContextLogger

func (*LoggerAdapter) Debugf

func (l *LoggerAdapter) Debugf(format string, v ...interface{})

Debugf implements ContextLogger

func (*LoggerAdapter) Errorf

func (l *LoggerAdapter) Errorf(format string, v ...interface{})

Errorf implements ContextLogger

func (*LoggerAdapter) Infof

func (l *LoggerAdapter) Infof(format string, v ...interface{})

Infof implements ContextLogger

func (*LoggerAdapter) IsShowSQL

func (l *LoggerAdapter) IsShowSQL() bool

IsShowSQL implements ContextLogger

func (*LoggerAdapter) Level

func (l *LoggerAdapter) Level() LogLevel

Level implements ContextLogger

func (*LoggerAdapter) SetLevel

func (l *LoggerAdapter) SetLevel(lv LogLevel)

SetLevel implements ContextLogger

func (*LoggerAdapter) ShowSQL

func (l *LoggerAdapter) ShowSQL(show ...bool)

ShowSQL implements ContextLogger

func (*LoggerAdapter) Warnf

func (l *LoggerAdapter) Warnf(format string, v ...interface{})

Warnf implements ContextLogger

type SQLLogger

type SQLLogger interface {
	BeforeSQL(context LogContext) // only invoked when IsShowSQL is true
	AfterSQL(context LogContext)  // only invoked when IsShowSQL is true
}

SQLLogger represents an interface to log SQL

type SimpleLogger

type SimpleLogger struct {
	DEBUG *log.Logger
	ERR   *log.Logger
	INFO  *log.Logger
	WARN  *log.Logger
	// contains filtered or unexported fields
}

SimpleLogger is the default implment of ILogger

func NewSimpleLogger

func NewSimpleLogger(out io.Writer) *SimpleLogger

NewSimpleLogger use a special io.Writer as logger output

func NewSimpleLogger2

func NewSimpleLogger2(out io.Writer, prefix string, flag int) *SimpleLogger

NewSimpleLogger2 let you customrize your logger prefix and flag

func NewSimpleLogger3

func NewSimpleLogger3(out io.Writer, prefix string, flag int, l LogLevel) *SimpleLogger

NewSimpleLogger3 let you customrize your logger prefix and flag and logLevel

func (*SimpleLogger) Debug

func (s *SimpleLogger) Debug(v ...interface{})

Debug implement ILogger

func (*SimpleLogger) Debugf

func (s *SimpleLogger) Debugf(format string, v ...interface{})

Debugf implement ILogger

func (*SimpleLogger) Error

func (s *SimpleLogger) Error(v ...interface{})

Error implement ILogger

func (*SimpleLogger) Errorf

func (s *SimpleLogger) Errorf(format string, v ...interface{})

Errorf implement ILogger

func (*SimpleLogger) Info

func (s *SimpleLogger) Info(v ...interface{})

Info implement ILogger

func (*SimpleLogger) Infof

func (s *SimpleLogger) Infof(format string, v ...interface{})

Infof implement ILogger

func (*SimpleLogger) IsShowSQL

func (s *SimpleLogger) IsShowSQL() bool

IsShowSQL implement ILogger

func (*SimpleLogger) Level

func (s *SimpleLogger) Level() LogLevel

Level implement ILogger

func (*SimpleLogger) SetLevel

func (s *SimpleLogger) SetLevel(l LogLevel)

SetLevel implement ILogger

func (*SimpleLogger) ShowSQL

func (s *SimpleLogger) ShowSQL(show ...bool)

ShowSQL implement ILogger

func (*SimpleLogger) Warn

func (s *SimpleLogger) Warn(v ...interface{})

Warn implement ILogger

func (*SimpleLogger) Warnf

func (s *SimpleLogger) Warnf(format string, v ...interface{})

Warnf implement ILogger

type SyslogLogger

type SyslogLogger struct {
	// contains filtered or unexported fields
}

SyslogLogger will be depricated

func NewSyslogLogger

func NewSyslogLogger(w *syslog.Writer) *SyslogLogger

NewSyslogLogger implements Logger

func (*SyslogLogger) Debug

func (s *SyslogLogger) Debug(v ...interface{})

Debug log content as Debug

func (*SyslogLogger) Debugf

func (s *SyslogLogger) Debugf(format string, v ...interface{})

Debugf log content as Debug and format

func (*SyslogLogger) Error

func (s *SyslogLogger) Error(v ...interface{})

Error log content as Error

func (*SyslogLogger) Errorf

func (s *SyslogLogger) Errorf(format string, v ...interface{})

Errorf log content as Errorf and format

func (*SyslogLogger) Info

func (s *SyslogLogger) Info(v ...interface{})

Info log content as Info

func (*SyslogLogger) Infof

func (s *SyslogLogger) Infof(format string, v ...interface{})

Infof log content as Infof and format

func (*SyslogLogger) IsShowSQL

func (s *SyslogLogger) IsShowSQL() bool

IsShowSQL if logging SQL

func (*SyslogLogger) Level

func (s *SyslogLogger) Level() LogLevel

Level shows log level

func (*SyslogLogger) SetLevel

func (s *SyslogLogger) SetLevel(l LogLevel)

SetLevel always return error, as current log/syslog package doesn't allow to set priority level after syslog.Writer created

func (*SyslogLogger) ShowSQL

func (s *SyslogLogger) ShowSQL(show ...bool)

ShowSQL set if logging SQL

func (*SyslogLogger) Warn

func (s *SyslogLogger) Warn(v ...interface{})

Warn log content as Warn

func (*SyslogLogger) Warnf

func (s *SyslogLogger) Warnf(format string, v ...interface{})

Warnf log content as Warnf and format

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto