engine: github.com/g3n/engine/util/logger Index | Files

package logger

import "github.com/g3n/engine/util/logger"

Package logger implements an hierarchical logger used by other packages.

Index

Package Files

console.go doc.go file.go logger.go net.go

Constants

const (
    DEBUG = iota
    INFO
    WARN
    ERROR
    FATAL
)

Levels to filter log output

const (
    // Show date
    FDATE = 1 << iota
    // Show hour, minutes and seconds
    FTIME
    // Show milliseconds after FTIME
    FMILIS
    // Show microseconds after FTIME
    FMICROS
    // Show nanoseconfs after TIME
    FNANOS
)

Flags used to format the log date/time

func AddWriter Uses

func AddWriter(writer LoggerWriter)

AddWriter adds a writer to the current outputs of the default logger.

func Debug Uses

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

Debug emits a DEBUG level log message

func Error Uses

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

Error emits an ERROR level log message

func Fatal Uses

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

Fatal emits a FATAL level log message

func Info Uses

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

Info emits an INFO level log message

func Log Uses

func Log(level int, format string, v ...interface{})

Log emits a log message with the specified level

func SetFormat Uses

func SetFormat(format int)

SetFormat sets the date/time message format of the default logger.

func SetLevel Uses

func SetLevel(level int)

SetLevel sets the current level of the default logger. Only log messages with levels with the same or higher priorities than the current level will be emitted.

func SetLevelByName Uses

func SetLevelByName(lname string)

SetLevelByName sets the current level of the default logger by level name: debug|info|warn|error|fatal (case ignored.) Only log messages with levels with the same or higher priorities than the current level will be emitted.

func Warn Uses

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

Warn emits a WARN level log message

type Console Uses

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

Console is a console writer used for logging.

func NewConsole Uses

func NewConsole(color bool) *Console

NewConsole creates and returns a new logger Console writer If color is true, this writer uses Ansi codes to write log messages in color accordingly to its level.

func (*Console) Close Uses

func (w *Console) Close()

func (*Console) Sync Uses

func (w *Console) Sync()

func (*Console) Write Uses

func (w *Console) Write(event *Event)

Write writes the provided logger event to the console.

type Event Uses

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

Event is a logger event passed from the logger to its writers.

type File Uses

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

File is a file writer used for logging.

func NewFile Uses

func NewFile(filename string) (*File, error)

NewFile creates and returns a pointer to a new File object along with any error that occurred.

func (*File) Close Uses

func (f *File) Close()

Close closes the file.

func (*File) Sync Uses

func (f *File) Sync()

Sync commits the current contents of the file to stable storage.

func (*File) Write Uses

func (f *File) Write(event *Event)

Write writes the provided logger event to the file.

type Logger Uses

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

Logger Object state structure

var Default *Logger

Default logger and global mutex

func Find Uses

func Find(path string) *Logger

Find finds a logger with the specified path.

func New Uses

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

New creates and returns a new logger with the specified name. If a parent logger is specified, the created logger inherits the parent's configuration.

func (*Logger) AddWriter Uses

func (l *Logger) AddWriter(writer LoggerWriter)

AddWriter adds a writer to the current outputs of this logger.

func (*Logger) Debug Uses

func (l *Logger) Debug(format string, v ...interface{})

Debug emits a DEBUG level log message

func (*Logger) EnableChild Uses

func (l *Logger) EnableChild(name string, state bool)

EnableChild enables or disables this logger child logger with the specified name.

func (*Logger) Error Uses

func (l *Logger) Error(format string, v ...interface{})

Error emits an ERROR level log message

func (*Logger) Fatal Uses

func (l *Logger) Fatal(format string, v ...interface{})

Fatal emits a FATAL level log message

func (*Logger) Info Uses

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

Info emits an INFO level log message

func (*Logger) Log Uses

func (l *Logger) Log(level int, format string, v ...interface{})

Log emits a log message with the specified level

func (*Logger) RemoveWriter Uses

func (l *Logger) RemoveWriter(writer LoggerWriter)

RemoveWriter removes the specified writer from the current outputs of this logger.

func (*Logger) SetFormat Uses

func (l *Logger) SetFormat(format int)

SetFormat sets the logger date/time message format

func (*Logger) SetLevel Uses

func (l *Logger) SetLevel(level int)

SetLevel sets the current level of this logger. Only log messages with levels with the same or higher priorities than the current level will be emitted.

func (*Logger) SetLevelByName Uses

func (l *Logger) SetLevelByName(lname string) error

SetLevelByName sets the current level of this logger by level name: debug|info|warn|error|fatal (case ignored.) Only log messages with levels with the same or higher priorities than the current level will be emitted.

func (*Logger) Warn Uses

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

Warn emits a WARN level log message

type LoggerWriter Uses

type LoggerWriter interface {
    Write(*Event)
    Close()
    Sync()
}

LoggerWriter is the interface for all logger writers

type Net Uses

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

Net is a network writer used for logging.

func NewNet Uses

func NewNet(network string, address string) (*Net, error)

NewNet creates and returns a pointer to a new Net object along with any error that occurred.

func (*Net) Close Uses

func (n *Net) Close()

Clone closes the network connection.

func (*Net) Sync Uses

func (n *Net) Sync()

func (*Net) Write Uses

func (n *Net) Write(event *Event)

Write writes the provided logger event to the network.

Package logger imports 6 packages (graph) and is imported by 22 packages. Updated 2018-06-27. Refresh now. Tools for package owners.