logger

package
v0.0.0-...-c2c5ea0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2017 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package logger implements an hierachical logger used by other packages.

Index

Constants

View Source
const (
	DEBUG = iota
	INFO
	WARN
	ERROR
	FATAL
)

Levels to filter log output

View Source
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

Variables

This section is empty.

Functions

func AddWriter

func AddWriter(writer LoggerWriter)

func Debug

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

func Error

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

func Fatal

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

func Info

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

func Log

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

func SetFormat

func SetFormat(format int)

func SetLevel

func SetLevel(level int)

func SetLevelByName

func SetLevelByName(lname string)

func Warn

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

Types

type Console

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

logger Console writer type

func NewConsole

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

func (w *Console) Close()

func (*Console) Sync

func (w *Console) Sync()

func (*Console) Write

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

type Event

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

Logger event passed from the logger to its writers.

type File

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

func NewFile

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

func (*File) Close

func (f *File) Close()

func (*File) Sync

func (f *File) Sync()

func (*File) Write

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

type Logger

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

Logger Object state structure

var Default *Logger = nil

Default logger and global mutex

func Find

func Find(path string) *Logger

Find finds a logger with the specified path.

func New

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

func (self *Logger) AddWriter(writer LoggerWriter)

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

func (*Logger) Debug

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

Debug emits a DEBUG level log message

func (*Logger) EnableChild

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

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

func (*Logger) Error

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

Error emits an ERROR level log message

func (*Logger) Fatal

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

Fatal emits a FATAL level log message

func (*Logger) Info

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

Info emits an INFO level log message

func (*Logger) Log

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

Logs emits a log message with the specified level

func (*Logger) RemoveWriter

func (self *Logger) RemoveWriter(writer LoggerWriter)

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

func (*Logger) SetFormat

func (self *Logger) SetFormat(format int)

SetFormat sets the logger date/time message format

func (*Logger) SetLevel

func (self *Logger) SetLevel(level int)

SetLevel set 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

func (self *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

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

Warn emits a WARN level log message

type LoggerWriter

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

Interface for all logger writers

type Net

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

func NewNet

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

func (*Net) Close

func (n *Net) Close()

func (*Net) Sync

func (n *Net) Sync()

func (*Net) Write

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL