clog: github.com/go-clog/clog Index | Files

package clog

import "github.com/go-clog/clog"

Clog is a channel-based logging package for Go.

Index

Package Files

clog.go console.go discord.go error.go file.go logger.go slack.go

Constants

const (
    SIMPLE_DATE_FORMAT = "2006-01-02"
    LOG_PREFIX_LENGTH  = len("2017/02/06 21:20:08 ")
)

func Delete Uses

func Delete(mode MODE)

Delete removes logger from the receiver list.

func Error Uses

func Error(skip int, format string, v ...interface{})

func Fatal Uses

func Fatal(skip int, format string, v ...interface{})

func Info Uses

func Info(format string, v ...interface{})

func New Uses

func New(mode MODE, cfg interface{}) error

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 Uses

func NewFileWriter(filename string, cfg FileRotationConfig) (io.Writer, error)

NewFileWriter returns an io.Writer for synchronized file logger in standalone mode.

func Register Uses

func Register(mode MODE, f Factory)

func Shutdown Uses

func Shutdown()

func Trace Uses

func Trace(format string, v ...interface{})

func Version Uses

func Version() string

Version returns current version of the package.

func Warn Uses

func Warn(format string, v ...interface{})

func Write Uses

func Write(level LEVEL, skip int, format string, v ...interface{})

type Adapter Uses

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 Uses

type ConsoleConfig struct {
    // Minimum level of messages to be processed.
    Level LEVEL
    // Buffer size defines how many messages can be queued before hangs.
    BufferSize int64
}

type DiscordConfig Uses

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 Uses

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

func (ErrConfigObject) Error Uses

func (err ErrConfigObject) Error() string

type ErrInvalidLevel Uses

type ErrInvalidLevel struct{}

func (ErrInvalidLevel) Error Uses

func (err ErrInvalidLevel) Error() string

type Factory Uses

type Factory func() Logger

type FileConfig Uses

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 Uses

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 LEVEL Uses

type LEVEL int
const (
    TRACE LEVEL = iota
    INFO
    WARN
    ERROR
    FATAL
)

type Logger Uses

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 MODE Uses

type MODE string
const (
    CONSOLE MODE = "console"
    FILE    MODE = "file"
    SLACK   MODE = "slack"
    DISCORD MODE = "discord"
)

type Message Uses

type Message struct {
    Level LEVEL
    Body  string
}

Message represents a log message to be processed.

type SlackConfig Uses

type SlackConfig struct {
    // Minimum level of messages to be processed.
    Level LEVEL
    // Buffer size defines how many messages can be queued before hangs.
    BufferSize int64
    // Slack webhook URL.
    URL string
}

Package clog imports 14 packages (graph) and is imported by 5 packages. Updated 2019-07-13. Refresh now. Tools for package owners.