Back to godoc.org
github.com/simia-tech/gol

package gol

v0.0.0 (6108c1c)
Latest Go to latest
Published: Jun 1, 2015 | License: Apache-2.0 | Module: github.com/simia-tech/gol

Overview

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

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

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

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

func Debug

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

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

func Error

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

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

func Handle

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

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

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

func Initialize

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

func Panic(v interface{})

func Protocol

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

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

func Warning

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

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

type Configuration

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.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier