gol: github.com/simia-tech/gol Index | Files

package gol

import "github.com/simia-tech/gol"

gol is an extended logger for go, that can log to a console, file and syslog backend via a single interface. It supports multiple logging channels and the output can be filtered using a mask. On top of this, multiple of backends can be used at the same time.

Index

Package Files

backend.go channel.go color.go configuration.go gol.go level.go mapper.go mask.go

Constants

const (
    BACKEND_CONSOLE backend = "console"
    BACKEND_FILE    backend = "file"
    BACKEND_SYSLOG  backend = "syslog"
)
const (
    LEVEL_CRITICAL level = 1 << iota
    LEVEL_ERROR
    LEVEL_WARNING
    LEVEL_INFO
    LEVEL_DEBUG
    LEVEL_PROTOCOL
)
const (
    MASK_ALL     mask = mask(LEVEL_CRITICAL) | mask(LEVEL_ERROR) | mask(LEVEL_WARNING) | mask(LEVEL_INFO) | mask(LEVEL_DEBUG) | mask(LEVEL_PROTOCOL)
    MASK_DEBUG   mask = mask(LEVEL_CRITICAL) | mask(LEVEL_ERROR) | mask(LEVEL_WARNING) | mask(LEVEL_INFO) | mask(LEVEL_DEBUG)
    MASK_DEFAULT mask = mask(LEVEL_CRITICAL) | mask(LEVEL_ERROR) | mask(LEVEL_WARNING) | mask(LEVEL_INFO)
    MASK_WARNING mask = mask(LEVEL_CRITICAL) | mask(LEVEL_ERROR) | mask(LEVEL_WARNING)
)

func Critical Uses

func Critical(format string, values ...interface{})

Critical uses format and values to generate a log message on the critical channel.

func Debug Uses

func Debug(format string, values ...interface{})

Debug uses format and values to generate a log message on the debug channel.

func Error Uses

func Error(format string, values ...interface{})

Error uses format and values to generate a log message on the error channel.

func Handle Uses

func Handle(err error, levels ...level)

Handle takes the given error and writes it to all channels that correspond to the given levels. If no level is given, the error will be published on the error channel.

func Info Uses

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

Info uses format and values to generate a log message on the info channel.

func Initialize Uses

func Initialize(configurations ...*Configuration) error

Initialize sets up gol with a number of given configurations. Each configuration specified a single backend. By default, no backend is specified. In order to see any log message, Initialize has to be called.

For example

gol.Initialize(&gol.Configuration{Backend: "console", Mask: "all"})

will log all messages to the console.

func Panic Uses

func Panic(v interface{})

func Protocol Uses

func Protocol(format string, values ...interface{})

Debug uses format and values to generate a log message on the debug channel.

func Warning Uses

func Warning(format string, values ...interface{})

Warning uses format and values to generate a log message on the warning channel.

type Configuration Uses

type Configuration struct {
    // common
    Backend string `json:"backend"`
    Mask    string `json:"mask"`

    // console
    Color bool `json:"color"`

    // file
    Path string `json:"path"`
    Mode string `json:"mode"`

    // syslog
    Prefix string `json:"prefix"`
}

Configuration holds all information that specify a single gol backend. While the common properties are needed for each backend, it holds also backend-specific properties.

Package gol imports 8 packages (graph) and is imported by 1 packages. Updated 2016-11-06. Refresh now. Tools for package owners.