Documentation
¶
Index ¶
- Variables
- func Alert(args ...interface{})
- func Close() (err error)
- func Configure(cnf *Configuration) error
- func Critical(args ...interface{})
- func CustomMessage(msg *m.Message)
- func Debug(args ...interface{})
- func DelModuleName()
- func Error(args ...interface{})
- func Fatal(args ...interface{})
- func GetWriter() *w.Writer
- func Info(args ...interface{})
- func InterceptStandardLog(flg bool)
- func Message(level l.Level, args ...interface{})
- func Notice(args ...interface{})
- func SetApplicationName(name string)
- func SetModuleName(name string)
- func Warning(args ...interface{})
- type Configuration
- type ConfigurationGraylog2
- type ConfigurationTelegram
- type Log
- type LogEssence
- func (log *LogEssence) Alert(args ...interface{}) Log
- func (log *LogEssence) Close() (err error)
- func (self *LogEssence) Configure(cnf *Configuration) (err error)
- func (log *LogEssence) Critical(args ...interface{}) Log
- func (log *LogEssence) CustomMessage(msg *m.Message) *LogEssence
- func (log *LogEssence) Debug(args ...interface{}) Log
- func (log *LogEssence) DelModuleName() Log
- func (log *LogEssence) Error(args ...interface{}) Log
- func (log *LogEssence) Fatal(args ...interface{})
- func (log *LogEssence) GetWriter() *w.Writer
- func (log *LogEssence) Info(args ...interface{}) Log
- func (log *LogEssence) Initialize() *LogEssence
- func (log *LogEssence) InterceptStandardLog(flg bool) Log
- func (log *LogEssence) Message(level l.Level, args ...interface{}) Log
- func (log *LogEssence) Notice(args ...interface{}) Log
- func (self *LogEssence) ResolveNames(rec *r.Record)
- func (log *LogEssence) SetApplicationName(name string) Log
- func (log *LogEssence) SetModuleName(name string) Log
- func (log *LogEssence) Warning(args ...interface{}) Log
Constants ¶
This section is empty.
Variables ¶
var ( ERROR_LEVEL_UNKNOWN = errors.New(`Unknown or not supported logging level`) // Указан не известный уровень логирования ERROR_CONFIGURATION_IS_NULL = errors.New(`The configuration does not initialized. Received nil instead of the object`) // The configuration does not initialized. Received nil instead of the object ERROR_UNKNOWN_MODE = errors.New(`Unknown logging mode`) // Unknown logging mode ERROR_LOG_FILENAME_IS_EMPTY = errors.New(`Log file name not specified`) // Log file name not specified ERROR_INIT_FILE_BACKEND = errors.New(`Can't initiate file backend`) // Can't initiate file backend )
Standart exported errors
Functions ¶
func Alert ¶
func Alert(args ...interface{})
Level 1 Alert: action must be taken immediately Should be corrected immediately - notify staff who can fix the problem - example is loss of backup ISP connection
func Critical ¶
func Critical(args ...interface{})
Level 2 Critical: critical conditions Should be corrected immediately, but indicates failure in a primary system - fix CRITICAL problems before ALERT - example is loss of primary ISP connection
func CustomMessage ¶
CustomMessage Push custom created log message
func Debug ¶
func Debug(args ...interface{})
Level 7 Debug: debug-level messages Info useful to developers for debugging the app, not useful during operations
func Error ¶
func Error(args ...interface{})
Level 3 Error: error conditions Non-urgent failures - these should be relayed to developers or admins; each item must be resolved within a given time
func Fatal ¶
func Fatal(args ...interface{})
Level 0 Fatal: system is unusable A "panic" condition - notify all tech staff on call? (earthquake? tornado?) - affects multiple apps/servers/sites...
func Info ¶
func Info(args ...interface{})
Level 6 Informational: informational messages Normal operational messages - may be harvested for reporting, measuring throughput, etc - no action required
func InterceptStandardLog ¶
func InterceptStandardLog(flg bool)
Configuring the interception of communications of a standard log flg=true - intercept is enabled flg=false - intercept is desabled
func Notice ¶
func Notice(args ...interface{})
Level 5 Notice: normal but significant condition Events that are unusual but not error conditions - might be summarized in an email to developers or admins to spot potential problems - no immediate action required
func SetApplicationName ¶
func SetApplicationName(name string)
Set application name If name is empty, get name from os.Args[0] (string)
func SetModuleName ¶
func SetModuleName(name string)
Set module name If module name is empty or not set, name equals package name
Types ¶
type Configuration ¶
type Configuration struct { BufferFlushImmediately bool `yaml:"BufferFlushImmediately"` // Сбрасывать буффер памяти сразу после записи строки (default: true - unbuffered) BufferSize int `yaml:"BufferSize"` // Размер буфера памяти в байтах (default: 0 - equal unbuffered) Mode map[b.BackendName][]l.LevelName `yaml:"Mode"` // Режим логирования, перечисляются включенные режимы логирования Levels map[b.BackendName]l.LevelName `yaml:"Levels"` // Уровень логирования для каждого режима логирования Formats map[b.BackendName]string `yaml:"Formats"` // Формат строки лога для каждого из режимов. Еслине описан, то берётся Format Format string `yaml:"Format"` // Формат по умолчанию для всех режимов File string `yaml:"File"` // Режим вывода в файл, путь и имя файла лога Graylog2 ConfigurationGraylog2 `yaml:"Graylog2"` // Настройки подключения к graylog серверу Telegram ConfigurationTelegram `yaml:"Telegram"` // Настройка отправки сообщений в telegram }
Log configuration
type ConfigurationGraylog2 ¶
type ConfigurationGraylog2 struct { Host string `yaml:"Host"` // IP адрес или имя хоста Graylog сервера Port uint16 `yaml:"Port"` // Порт на котором находится Graylog сервер Protocol string `yaml:"Protocol"` // Протокол передачи данных, возможные значения: tcp, udp. По умолчанию: udp Source string `yaml:"Source"` // Наименование источника логов ChunkSize uint `yaml:"ChunkSize"` // Максимальный размер отправляемого пакета Compression g.CompressionType `yaml:"Compression"` // Сжатие передаваемых пакетов данных BufferSize int64 `yaml:"BufferSize"` // Размер буфера ??? }
Graylog server configuration
type Log ¶
type Log interface { Fatal(...interface{}) // Alert(...interface{}) Log // Critical(...interface{}) Log // Error(...interface{}) Log // Warning(...interface{}) Log // Notice(...interface{}) Log // Info(...interface{}) Log // Debug(...interface{}) Log // Message(l.Level, ...interface{}) Log // Configure(*Configuration) error // Close() error // SetApplicationName(string) Log // SetModuleName(string) Log // DelModuleName() Log // InterceptStandardLog(bool) Log // GetWriter() *w.Writer // // contains filtered or unexported methods }
Log
type LogEssence ¶
type LogEssence struct { Id u.UUID // The object identifier BufferSize int // Size memory buffer for log messages BufferFlushImmediately bool // Flush log buffer after call Writer *bufio.Writer // Log writer AppName string // %{program} - Application name HostName string // %{hostname} - Server host name Interface Log // The interface of the object // contains filtered or unexported fields }
LogEssence
func (*LogEssence) Alert ¶
func (log *LogEssence) Alert(args ...interface{}) Log
Level 1 Alert: action must be taken immediately Should be corrected immediately - notify staff who can fix the problem - example is loss of backup ISP connection
func (*LogEssence) Configure ¶
func (self *LogEssence) Configure(cnf *Configuration) (err error)
Apply new configuration
func (*LogEssence) Critical ¶
func (log *LogEssence) Critical(args ...interface{}) Log
Level 2 Critical: critical conditions Should be corrected immediately, but indicates failure in a primary system - fix CRITICAL problems before ALERT - example is loss of primary ISP connection
func (*LogEssence) CustomMessage ¶
func (log *LogEssence) CustomMessage(msg *m.Message) *LogEssence
CustomMessage Push custom created log message
func (*LogEssence) Debug ¶
func (log *LogEssence) Debug(args ...interface{}) Log
Level 7 Debug: debug-level messages Info useful to developers for debugging the app, not useful during operations
func (*LogEssence) Error ¶
func (log *LogEssence) Error(args ...interface{}) Log
Level 3 Error: error conditions Non-urgent failures - these should be relayed to developers or admins; each item must be resolved within a given time
func (*LogEssence) Fatal ¶
func (log *LogEssence) Fatal(args ...interface{})
Level 0 Fatal: system is unusable A "panic" condition - notify all tech staff on call? (earthquake? tornado?) - affects multiple apps/servers/sites...
func (*LogEssence) GetWriter ¶
func (log *LogEssence) GetWriter() *w.Writer
GetWriter Returns the standard writer to logging
func (*LogEssence) Info ¶
func (log *LogEssence) Info(args ...interface{}) Log
Level 6 Informational: informational messages Normal operational messages - may be harvested for reporting, measuring throughput, etc - no action required
func (*LogEssence) Initialize ¶
func (log *LogEssence) Initialize() *LogEssence
Initialize default configuration
func (*LogEssence) InterceptStandardLog ¶
func (log *LogEssence) InterceptStandardLog(flg bool) Log
Configuring the interception of communications of a standard log flg=true - intercept is enabled flg=false - intercept is desabled
func (*LogEssence) Message ¶
func (log *LogEssence) Message(level l.Level, args ...interface{}) Log
Message To send a message to the log with the level of logging
func (*LogEssence) Notice ¶
func (log *LogEssence) Notice(args ...interface{}) Log
Level 5 Notice: normal but significant condition Events that are unusual but not error conditions - might be summarized in an email to developers or admins to spot potential problems - no immediate action required
func (*LogEssence) ResolveNames ¶
func (self *LogEssence) ResolveNames(rec *r.Record)
Resolve resord
func (*LogEssence) SetApplicationName ¶
func (log *LogEssence) SetApplicationName(name string) Log
Set application name
func (*LogEssence) SetModuleName ¶
func (log *LogEssence) SetModuleName(name string) Log
Set module name
func (*LogEssence) Warning ¶
func (log *LogEssence) Warning(args ...interface{}) Log
Level 4 Warning: warning conditions Warning messages - not an error, but indication that an error will occur if action is not taken, e.g. file system 85% full - each item must be resolved within a given time