xorm: xorm.io/xorm/log Index | Files

package log

import "xorm.io/xorm/log"

Index

Package Files

logger.go logger_context.go syslogger.go

Constants

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

default log options

Variables

var (
    SessionIDKey      = "__xorm_session_id"
    SessionShowSQLKey = "__xorm_show_sql"
)

enumerate all the context keys

type ContextLogger Uses

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 Uses

func NewLoggerAdapter(logger Logger) ContextLogger

NewLoggerAdapter creates an adapter for old xorm logger interface

type DiscardLogger Uses

type DiscardLogger struct{}

DiscardLogger don't log implementation for ILogger

func (DiscardLogger) Debug Uses

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

Debug empty implementation

func (DiscardLogger) Debugf Uses

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

Debugf empty implementation

func (DiscardLogger) Error Uses

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

Error empty implementation

func (DiscardLogger) Errorf Uses

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

Errorf empty implementation

func (DiscardLogger) Info Uses

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

Info empty implementation

func (DiscardLogger) Infof Uses

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

Infof empty implementation

func (DiscardLogger) IsShowSQL Uses

func (DiscardLogger) IsShowSQL() bool

IsShowSQL empty implementation

func (DiscardLogger) Level Uses

func (DiscardLogger) Level() LogLevel

Level empty implementation

func (DiscardLogger) SetLevel Uses

func (DiscardLogger) SetLevel(l LogLevel)

SetLevel empty implementation

func (DiscardLogger) ShowSQL Uses

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

ShowSQL empty implementation

func (DiscardLogger) Warn Uses

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

Warn empty implementation

func (DiscardLogger) Warnf Uses

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

Warnf empty implementation

type LogContext Uses

type LogContext contexts.ContextHook

LogContext represents a log context

type LogLevel Uses

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 Uses

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 Uses

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

LoggerAdapter wraps a Logger interface as LoggerContext interface

func (*LoggerAdapter) AfterSQL Uses

func (l *LoggerAdapter) AfterSQL(ctx LogContext)

AfterSQL implements ContextLogger

func (*LoggerAdapter) BeforeSQL Uses

func (l *LoggerAdapter) BeforeSQL(ctx LogContext)

BeforeSQL implements ContextLogger

func (*LoggerAdapter) Debugf Uses

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

Debugf implements ContextLogger

func (*LoggerAdapter) Errorf Uses

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

Errorf implements ContextLogger

func (*LoggerAdapter) Infof Uses

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

Infof implements ContextLogger

func (*LoggerAdapter) IsShowSQL Uses

func (l *LoggerAdapter) IsShowSQL() bool

IsShowSQL implements ContextLogger

func (*LoggerAdapter) Level Uses

func (l *LoggerAdapter) Level() LogLevel

Level implements ContextLogger

func (*LoggerAdapter) SetLevel Uses

func (l *LoggerAdapter) SetLevel(lv LogLevel)

SetLevel implements ContextLogger

func (*LoggerAdapter) ShowSQL Uses

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

ShowSQL implements ContextLogger

func (*LoggerAdapter) Warnf Uses

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

Warnf implements ContextLogger

type SQLLogger Uses

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 Uses

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 Uses

func NewSimpleLogger(out io.Writer) *SimpleLogger

NewSimpleLogger use a special io.Writer as logger output

func NewSimpleLogger2 Uses

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

NewSimpleLogger2 let you customrize your logger prefix and flag

func NewSimpleLogger3 Uses

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 Uses

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

Debug implement ILogger

func (*SimpleLogger) Debugf Uses

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

Debugf implement ILogger

func (*SimpleLogger) Error Uses

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

Error implement ILogger

func (*SimpleLogger) Errorf Uses

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

Errorf implement ILogger

func (*SimpleLogger) Info Uses

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

Info implement ILogger

func (*SimpleLogger) Infof Uses

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

Infof implement ILogger

func (*SimpleLogger) IsShowSQL Uses

func (s *SimpleLogger) IsShowSQL() bool

IsShowSQL implement ILogger

func (*SimpleLogger) Level Uses

func (s *SimpleLogger) Level() LogLevel

Level implement ILogger

func (*SimpleLogger) SetLevel Uses

func (s *SimpleLogger) SetLevel(l LogLevel)

SetLevel implement ILogger

func (*SimpleLogger) ShowSQL Uses

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

ShowSQL implement ILogger

func (*SimpleLogger) Warn Uses

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

Warn implement ILogger

func (*SimpleLogger) Warnf Uses

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

Warnf implement ILogger

type SyslogLogger Uses

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

SyslogLogger will be depricated

func NewSyslogLogger Uses

func NewSyslogLogger(w *syslog.Writer) *SyslogLogger

NewSyslogLogger implements Logger

func (*SyslogLogger) Debug Uses

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

Debug log content as Debug

func (*SyslogLogger) Debugf Uses

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

Debugf log content as Debug and format

func (*SyslogLogger) Error Uses

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

Error log content as Error

func (*SyslogLogger) Errorf Uses

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

Errorf log content as Errorf and format

func (*SyslogLogger) Info Uses

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

Info log content as Info

func (*SyslogLogger) Infof Uses

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

Infof log content as Infof and format

func (*SyslogLogger) IsShowSQL Uses

func (s *SyslogLogger) IsShowSQL() bool

IsShowSQL if logging SQL

func (*SyslogLogger) Level Uses

func (s *SyslogLogger) Level() LogLevel

Level shows log level

func (*SyslogLogger) SetLevel Uses

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 Uses

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

ShowSQL set if logging SQL

func (*SyslogLogger) Warn Uses

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

Warn log content as Warn

func (*SyslogLogger) Warnf Uses

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

Warnf log content as Warnf and format

Package log imports 5 packages (graph) and is imported by 11 packages. Updated 2020-07-07. Refresh now. Tools for package owners.