gol: github.com/goburrow/gol Index | Files | Directories

package gol

import "github.com/goburrow/gol"

Package gol provides a simple logging framework, inspired by SLF4J.


Package Files

api.go default.go gol.go nop.go


const (
    // RootLoggerName is the name of the root logger.
    RootLoggerName = "root"

func LevelString Uses

func LevelString(level Level) string

LevelString returns the text for the level.

func Print Uses

func Print(args ...interface{})

Print prints to standard error, used for debugging.

func SetDebugMode Uses

func SetDebugMode(val bool)

SetDebugMode sets debug mode in gol package.

type Appender Uses

type Appender interface {

Appender appends contents to a Writer.

type DefaultAppender Uses

type DefaultAppender struct {
    // contains filtered or unexported fields

DefaultAppender implements Appender interface.

func NewAppender Uses

func NewAppender(target io.Writer) *DefaultAppender

NewAppender allocates and returns a new DefaultAppender.

func (*DefaultAppender) Append Uses

func (appender *DefaultAppender) Append(event *LoggingEvent)

Append uses its encoder to send the event to the target.

type DefaultFactory Uses

type DefaultFactory struct {
    // contains filtered or unexported fields

DefaultFactory implements Factory interface.

func NewFactory Uses

func NewFactory(writer io.Writer) *DefaultFactory

NewFactory allocates and returns new DefaultFactory.

func (*DefaultFactory) GetLogger Uses

func (factory *DefaultFactory) GetLogger(name string) Logger

GetLogger returns a new Logger or an existing one if the same name is found.

type DefaultLogger Uses

type DefaultLogger struct {
    // contains filtered or unexported fields

DefaultLogger implements Logger interface.

func New Uses

func New(name string, parent *DefaultLogger) *DefaultLogger

New allocates and returns a new DefaultLogger. This method should not be called directly in application, use LoggerFactory.GetLogger() instead as a DefaultLogger requires Appender from itself or its parent.

func (*DefaultLogger) Appender Uses

func (logger *DefaultLogger) Appender() Appender

Appender returns appender of this logger or parent if not set.

func (*DefaultLogger) DebugEnabled Uses

func (logger *DefaultLogger) DebugEnabled() bool

DebugEnabled checks if Debug level is enabled.

func (*DefaultLogger) Debugf Uses

func (logger *DefaultLogger) Debugf(format string, args ...interface{})

Debugf logs message at Debug level.

func (*DefaultLogger) ErrorEnabled Uses

func (logger *DefaultLogger) ErrorEnabled() bool

ErrorEnabled checks if Error level is enabled.

func (*DefaultLogger) Errorf Uses

func (logger *DefaultLogger) Errorf(format string, args ...interface{})

Errorf logs message at Error level.

func (*DefaultLogger) InfoEnabled Uses

func (logger *DefaultLogger) InfoEnabled() bool

InfoEnabled checks if Info level is enabled.

func (*DefaultLogger) Infof Uses

func (logger *DefaultLogger) Infof(format string, args ...interface{})

Infof logs message at Info level.

func (*DefaultLogger) Level Uses

func (logger *DefaultLogger) Level() Level

Level returns level of this logger or parent if not set.

func (*DefaultLogger) Printf Uses

func (logger *DefaultLogger) Printf(level Level, format string, args []interface{})

log performs logging with given parameters.

func (*DefaultLogger) SetAppender Uses

func (logger *DefaultLogger) SetAppender(appender Appender)

SetAppender changes appender of this logger.

func (*DefaultLogger) SetLevel Uses

func (logger *DefaultLogger) SetLevel(level Level)

SetLevel changes logging level of this logger.

func (*DefaultLogger) TraceEnabled Uses

func (logger *DefaultLogger) TraceEnabled() bool

TraceEnabled checks if Trace level is enabled.

func (*DefaultLogger) Tracef Uses

func (logger *DefaultLogger) Tracef(format string, args ...interface{})

Tracef logs message at Trace level.

func (*DefaultLogger) WarnEnabled Uses

func (logger *DefaultLogger) WarnEnabled() bool

WarnEnabled checks if Warning level is enabled.

func (*DefaultLogger) Warnf Uses

func (logger *DefaultLogger) Warnf(format string, args ...interface{})

Warnf logs message at Warning level.

type Factory Uses

type Factory interface {
    GetLogger(name string) Logger

Factory produces Logger.

type Level Uses

type Level int

Level represents logging level.

const (
    Uninitialized Level = iota

Log levels

type Logger Uses

type Logger interface {
    Tracef(string, ...interface{})
    TraceEnabled() bool
    Debugf(string, ...interface{})
    DebugEnabled() bool
    Infof(string, ...interface{})
    InfoEnabled() bool
    Warnf(string, ...interface{})
    WarnEnabled() bool
    Errorf(string, ...interface{})
    ErrorEnabled() bool

Logger specifies how logging in application is done.

var (
    NOPLogger Logger = (*nopLogger)(nil)

func GetLogger Uses

func GetLogger(name string) Logger

GetLogger returns Logger in the default logger factory.

type LoggingEvent Uses

type LoggingEvent struct {
    // Name is the of the logger.
    Name string
    // Level is the current logger level.
    Level Level
    // Time is when the logging happens.
    Time time.Time

    Message bytes.Buffer

LoggingEvent is the representation of logging events.


asyncPackage async provides an asynchronous appender for gol.
filePackage file provides logging to file.
file/rotationPackage rotation provides triggering and rolling policy for system files.
filterPackage filter provides an appender which has filter.
logPackage log provides a bridge of default go log to gol.
syslogPackage syslog provides logging to syslog.

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