Documentation ¶
Index ¶
- Constants
- func Register(adapterName string, newLog adapterLoggerFunc)
- type AdapterApi
- type AdapterConsole
- type AdapterFile
- type ApiConfig
- type Config
- type ConsoleConfig
- type ConsoleWriter
- type FileConfig
- type FileWriter
- type Logger
- func (logger *Logger) Alert(msg string)
- func (logger *Logger) Alertf(format string, a ...interface{})
- func (logger *Logger) Attach(adapterName string, level int, config Config) error
- func (logger *Logger) Critical(msg string)
- func (logger *Logger) Criticalf(format string, a ...interface{})
- func (logger *Logger) Debug(msg string)
- func (logger *Logger) Debugf(format string, a ...interface{})
- func (logger *Logger) Detach(adapterName string) error
- func (logger *Logger) Emergency(msg string)
- func (logger *Logger) Emergencyf(format string, a ...interface{})
- func (logger *Logger) Error(msg string)
- func (logger *Logger) Errorf(format string, a ...interface{})
- func (logger *Logger) Flush()
- func (logger *Logger) Info(msg string)
- func (logger *Logger) Infof(format string, a ...interface{})
- func (logger *Logger) LoggerLevel(levelStr string) int
- func (logger *Logger) Notice(msg string)
- func (logger *Logger) Noticef(format string, a ...interface{})
- func (logger *Logger) SetAsync(data ...int)
- func (logger *Logger) SetWrapperLevel(wrapperLevel int)
- func (logger *Logger) Warning(msg string)
- func (logger *Logger) Warningf(format string, a ...interface{})
- func (logger *Logger) Writer(level int, msg string) error
- type LoggerAbstract
Constants ¶
View Source
const ( FILE_SLICE_DATE_NULL = "" FILE_SLICE_DATE_YEAR = "y" FILE_SLICE_DATE_MONTH = "m" FILE_SLICE_DATE_DAY = "d" FILE_SLICE_DATE_HOUR = "h" )
View Source
const ( LOGGER_LEVEL_EMERGENCY = iota LOGGER_LEVEL_ALERT LOGGER_LEVEL_CRITICAL LOGGER_LEVEL_ERROR LOGGER_LEVEL_WARNING LOGGER_LEVEL_NOTICE LOGGER_LEVEL_INFO LOGGER_LEVEL_DEBUG )
View Source
const API_ADAPTER_NAME = "api"
View Source
const CONSOLE_ADAPTER_NAME = "console"
View Source
const (
FILE_ACCESS_LEVEL = 1000
)
View Source
const FILE_ADAPTER_NAME = "file"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AdapterApi ¶
type AdapterApi struct {
// contains filtered or unexported fields
}
adapter api
func (*AdapterApi) Flush ¶
func (adapterApi *AdapterApi) Flush()
func (*AdapterApi) Init ¶
func (adapterApi *AdapterApi) Init(apiConfig Config) error
func (*AdapterApi) Name ¶
func (adapterApi *AdapterApi) Name() string
func (*AdapterApi) Write ¶
func (adapterApi *AdapterApi) Write(loggerMsg *loggerMessage) error
type AdapterConsole ¶
type AdapterConsole struct {
// contains filtered or unexported fields
}
adapter console
func (*AdapterConsole) Flush ¶
func (adapterConsole *AdapterConsole) Flush()
func (*AdapterConsole) Init ¶
func (adapterConsole *AdapterConsole) Init(consoleConfig Config) error
func (*AdapterConsole) Name ¶
func (adapterConsole *AdapterConsole) Name() string
func (*AdapterConsole) Write ¶
func (adapterConsole *AdapterConsole) Write(loggerMsg *loggerMessage) error
type AdapterFile ¶
type AdapterFile struct {
// contains filtered or unexported fields
}
adapter file
func (*AdapterFile) Write ¶
func (adapterFile *AdapterFile) Write(loggerMsg *loggerMessage) error
Write
type ApiConfig ¶
type ApiConfig struct { // request url adddress Url string // request method // GET, POST Method string // request headers Headers map[string]string // is verify response code IsVerify bool // verify response http code VerifyCode int }
api config
type ConsoleConfig ¶
type ConsoleConfig struct { // console text is show color Color bool // is json format JsonFormat bool // jsonFormat is false, please input format string // if format is empty, default format "%millisecond_format% [%level_string%] %body%" // // Timestamp "%timestamp%" // TimestampFormat "%timestamp_format%" // Millisecond "%millisecond%" // MillisecondFormat "%millisecond_format%" // Level int "%level%" // LevelString "%level_string%" // Body string "%body%" // File string "%file%" // Line int "%line%" // Function "%function%" // // example: format = "%millisecond_format% [%level_string%] %body%" Format string }
console config
func (*ConsoleConfig) Name ¶
func (cc *ConsoleConfig) Name() string
type ConsoleWriter ¶
type ConsoleWriter struct {
// contains filtered or unexported fields
}
console writer
type FileConfig ¶
type FileConfig struct { // log filename Filename string // level log filename LevelFileName map[int]string // max file size MaxSize int64 // max file line MaxLine int64 // file slice by date // "y" Log files are cut through year // "m" Log files are cut through mouth // "d" Log files are cut through day // "h" Log files are cut through hour DateSlice string // is json format JsonFormat bool // jsonFormat is false, please input format string // if format is empty, default format "%millisecond_format% [%level_string%] %body%" // // Timestamp "%timestamp%" // TimestampFormat "%timestamp_format%" // Millisecond "%millisecond%" // MillisecondFormat "%millisecond_format%" // Level int "%level%" // LevelString "%level_string%" // Body string "%body%" // File string "%file%" // Line int "%line%" // Function "%function%" // // example: format = "%millisecond_format% [%level_string%] %body%" Format string }
file config
func (*FileConfig) Name ¶
func (fc *FileConfig) Name() string
type FileWriter ¶
type FileWriter struct {
// contains filtered or unexported fields
}
file writer
func NewFileWrite ¶
func NewFileWrite(fn string) *FileWriter
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger logger
func (*Logger) Attach ¶
Attach start attach a logger adapter param : adapterName console | file | database | ... return : error
func (*Logger) Detach ¶
Detach start attach a logger adapter param : adapterName console | file | database | ... return : error
func (*Logger) Emergencyf ¶
Emergencyf log emergency format
func (*Logger) Flush ¶
func (logger *Logger) Flush()
Flush if SetAsync() or logger.synchronous is false, must call Flush() to flush msgChan data
func (*Logger) LoggerLevel ¶
LoggerLevel set logger level
func (*Logger) SetWrapperLevel ¶
SetWrapperLevel wrapper level
type LoggerAbstract ¶
type LoggerAbstract interface { Name() string Init(config Config) error Write(loggerMsg *loggerMessage) error Flush() }
func NewAdapterApi ¶
func NewAdapterApi() LoggerAbstract
func NewAdapterConsole ¶
func NewAdapterConsole() LoggerAbstract
func NewAdapterFile ¶
func NewAdapterFile() LoggerAbstract
Source Files ¶
Click to show internal directories.
Click to hide internal directories.