Documentation ¶
Overview ¶
Clog is a channel-based logging package for Go.
Index ¶
- Constants
- func Delete(mode MODE)
- func Error(skip int, format string, v ...interface{})
- func Fatal(skip int, format string, v ...interface{})
- func Info(format string, v ...interface{})
- func New(mode MODE, cfg interface{}) error
- func NewFileWriter(filename string, cfg FileRotationConfig) (io.Writer, error)
- func Register(mode MODE, f Factory)
- func Shutdown()
- func Trace(format string, v ...interface{})
- func Version() string
- func Warn(format string, v ...interface{})
- func Write(level LEVEL, skip int, format string, v ...interface{})
- type Adapter
- type ConsoleConfig
- type DiscordConfig
- type ErrConfigObject
- type ErrInvalidLevel
- type Factory
- type FileConfig
- type FileRotationConfig
- type LEVEL
- type Logger
- type MODE
- type Message
- type SlackConfig
Constants ¶
View Source
const ( SIMPLE_DATE_FORMAT = "2006-01-02" LOG_PREFIX_LENGTH = len("2017/02/06 21:20:08 ") )
Variables ¶
This section is empty.
Functions ¶
func New ¶
New initializes and appends a new logger to the receiver list. Calling this function multiple times will overwrite previous logger with same mode.
func NewFileWriter ¶ added in v1.1.0
func NewFileWriter(filename string, cfg FileRotationConfig) (io.Writer, error)
NewFileWriter returns an io.Writer for synchronized file logger in standalone mode.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter contains common fields for any logger adapter. This struct should be used as embedded struct.
type ConsoleConfig ¶
type DiscordConfig ¶ added in v1.2.0
type DiscordConfig struct { // Minimum level of messages to be processed. Level LEVEL // Buffer size defines how many messages can be queued before hangs. BufferSize int64 // Discord webhook URL. URL string // Username to be shown for the message. // Leave empty to use default as set in the Discord. Username string }
type ErrConfigObject ¶
type ErrConfigObject struct {
// contains filtered or unexported fields
}
func (ErrConfigObject) Error ¶
func (err ErrConfigObject) Error() string
type ErrInvalidLevel ¶
type ErrInvalidLevel struct{}
func (ErrInvalidLevel) Error ¶
func (err ErrInvalidLevel) Error() string
type FileConfig ¶
type FileConfig struct { // Minimum level of messages to be processed. Level LEVEL // Buffer size defines how many messages can be queued before hangs. BufferSize int64 // File name to outout messages. Filename string // Rotation related configurations. FileRotationConfig }
type FileRotationConfig ¶
type FileRotationConfig struct { // Do rotation for output files. Rotate bool // Rotate on daily basis. Daily bool // Maximum size in bytes of file for a rotation. MaxSize int64 // Maximum number of lines for a rotation. MaxLines int64 // Maximum lifetime of a output file in days. MaxDays int64 }
FileRotationConfig represents rotation related configurations for file mode logger. All the settings can take effect at the same time, remain zero values to disable them.
type Logger ¶
type Logger interface { // Level returns minimum level of given logger. Level() LEVEL // Init accepts a config struct specific for given logger and performs any necessary initialization. Init(interface{}) error // ExchangeChans accepts error channel, and returns message receive channel. ExchangeChans(chan<- error) chan *Message // Start starts message processing. Start() // Destroy releases all resources. Destroy() }
Logger is an interface for a logger adapter with specific mode and level.
type SlackConfig ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.