log

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2017 License: MIT Imports: 17 Imported by: 0

README

log

Logging

GoDoc

Disclaimer

This library is just a prototype at the moment. It's not ready for you to use. ... work in progress.

Dependencies
NONE
Install
go get gopkg.in/webnice/log.v1

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 Close

func Close() (err error)

Close logging and reinitialisation defailt log

func Configure

func Configure(cnf *Configuration) error

Configure log

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

func CustomMessage(msg *m.Message)

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 DelModuleName

func DelModuleName()

Remover module name

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 GetWriter

func GetWriter() *w.Writer

GetWriter Returns the standard writer to logging

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 Message

func Message(level l.Level, args ...interface{})

Message To send a message to the log with the level of logging

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

func Warning

func Warning(args ...interface{})

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

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 ConfigurationTelegram

type ConfigurationTelegram struct {
}

Telegram messenger 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

func GetDefaultLog

func GetDefaultLog() Log

Get default log object

func NewLog

func NewLog() Log

New log object

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) Close

func (log *LogEssence) Close() (err error)

Close logging

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) DelModuleName

func (log *LogEssence) DelModuleName() Log

Remove module name

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

Directories

Path Synopsis
Graylog2 GELF client
Graylog2 GELF client
http://tools.ietf.org/html/rfc4122
http://tools.ietf.org/html/rfc4122

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL