log

package
v1.7.1-0...-29a0ac7 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Red    = NewBrush("1;31")
	Purple = NewBrush("1;35")
	Yellow = NewBrush("1;33")
	Green  = NewBrush("1;32")
	Blue   = NewBrush("1;34")
	Cyan   = NewBrush("1;36")
)

Functions

func Close

func Close()

func ConsoleDebug

func ConsoleDebug(s string)

ConsoleDebug prints to stdout using DEBUG colors

func ConsoleDebugf

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

ConsoleDebugf prints a formatted string to stdout using DEBUG colors

func ConsoleError

func ConsoleError(s string)

ConsoleError prints to stdout using ERROR colors

func ConsoleErrorf

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

ConsoleErrorf prints a formatted string to stdout using ERROR colors

func ConsoleFatal

func ConsoleFatal(s string)

ConsoleFatal prints to stdout using FATAL colors

func ConsoleFatalf

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

ConsoleFatalf prints a formatted string to stdout using FATAL colors

func ConsoleInfo

func ConsoleInfo(s string)

ConsoleInfo prints to stdout using INFO colors

func ConsoleInfof

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

ConsoleInfof prints a formatted string to stdout using INFO colors

func ConsoleTrace

func ConsoleTrace(s string)

ConsoleTrace prints to stdout using TRACE colors

func ConsoleTracef

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

ConsoleTracef prints a formatted string to stdout using TRACE colors

func ConsoleWarn

func ConsoleWarn(s string)

ConsoleWarn prints to stdout using WARN colors

func ConsoleWarnf

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

ConsoleWarnf prints a formatted string to stdout using WARN colors

func Critical

func Critical(skip int, format string, v ...interface{})

func Debug

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

func Error

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

func Fatal

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

func Info

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

func Level

func Level(level LogLevel)

this helps you work around the performance annoyance mentioned in https://github.com/grafana/grafana/issues/4055 until we refactor this library completely

func NewLogger

func NewLogger(bufLen int64, mode, config string)

func Register

func Register(name string, log loggerType)

Register registers given logger provider to adapters.

func Trace

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

func Warn

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

Types

type Brush

type Brush func(string) string

func NewBrush

func NewBrush(color string) Brush

type ConsoleWriter

type ConsoleWriter struct {
	Level      LogLevel `json:"level"`
	Formatting bool     `json:"formatting"`
	// contains filtered or unexported fields
}

ConsoleWriter implements LoggerInterface and writes messages to terminal.

func (*ConsoleWriter) Destroy

func (_ *ConsoleWriter) Destroy()

func (*ConsoleWriter) Flush

func (_ *ConsoleWriter) Flush()

func (*ConsoleWriter) Init

func (cw *ConsoleWriter) Init(config string) error

func (*ConsoleWriter) WriteMsg

func (cw *ConsoleWriter) WriteMsg(msg string, skip int, level LogLevel) error

type FileLogWriter

type FileLogWriter struct {
	*log.Logger

	// The opened file
	Filename string `json:"filename"`

	Maxlines int `json:"maxlines"`

	// Rotate at size
	Maxsize int `json:"maxsize"`

	// Rotate daily
	Daily   bool  `json:"daily"`
	Maxdays int64 `json:"maxdays"`

	Rotate bool `json:"rotate"`

	Level LogLevel `json:"level"`
	// contains filtered or unexported fields
}

FileLogWriter implements LoggerInterface. It writes messages by lines limit, file size limit, or time frequency.

func (*FileLogWriter) Destroy

func (w *FileLogWriter) Destroy()

destroy file logger, close file writer.

func (*FileLogWriter) DoRotate

func (w *FileLogWriter) DoRotate() error

DoRotate means it need to write file in new file. new file name like xx.log.2013-01-01.2

func (*FileLogWriter) Flush

func (w *FileLogWriter) Flush()

flush file logger. there are no buffering messages in file logger in memory. flush file means sync file from disk.

func (*FileLogWriter) Init

func (w *FileLogWriter) Init(config string) error

Init file logger with json config. config like:

{
"filename":"log/gogs.log",
"maxlines":10000,
"maxsize":1<<30,
"daily":true,
"maxdays":15,
"rotate":true
}

func (*FileLogWriter) StartLogger

func (w *FileLogWriter) StartLogger() error

start file logger. create log file and set to locker-inside file writer.

func (*FileLogWriter) WriteMsg

func (w *FileLogWriter) WriteMsg(msg string, skip int, level LogLevel) error

write logger message into file.

type LogLevel

type LogLevel int
const (
	TRACE LogLevel = iota
	DEBUG
	INFO
	WARN
	ERROR
	CRITICAL
	FATAL
)

type Logger

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

Logger is default logger in beego application. it can contain several providers and log message into all providers.

func (*Logger) Close

func (l *Logger) Close()

Close closes logger, flush all chan data and destroy all adapter instances.

func (*Logger) Critical

func (l *Logger) Critical(skip int, format string, v ...interface{})

func (*Logger) Debug

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

func (*Logger) DelLogger

func (l *Logger) DelLogger(adapter string) error

DelLogger removes a logger adapter instance.

func (*Logger) Error

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

func (*Logger) Fatal

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

func (*Logger) Flush

func (l *Logger) Flush()

Flush flushs all chan data.

func (*Logger) Info

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

func (*Logger) SetLogger

func (l *Logger) SetLogger(adapter string, config string) error

SetLogger sets new logger instanse with given logger adapter and config.

func (*Logger) StartLogger

func (l *Logger) StartLogger()

StartLogger starts logger chan reading.

func (*Logger) Trace

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

func (*Logger) Warn

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

type LoggerInterface

type LoggerInterface interface {
	Init(config string) error
	WriteMsg(msg string, skip int, level LogLevel) error
	Destroy()
	Flush()
}

LoggerInterface represents behaviors of a logger provider.

func NewConsole

func NewConsole() LoggerInterface

create ConsoleWriter returning as LoggerInterface.

func NewFileWriter

func NewFileWriter() LoggerInterface

create a FileLogWriter returning as LoggerInterface.

func NewSyslog

func NewSyslog() LoggerInterface

type MuxWriter

type MuxWriter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

an *os.File writer with locker.

func (*MuxWriter) SetFd

func (l *MuxWriter) SetFd(fd *os.File)

set os.File in writer.

func (*MuxWriter) Write

func (l *MuxWriter) Write(b []byte) (int, error)

write to os.File.

type SyslogWriter

type SyslogWriter struct {
	Network  string `json:"network"`
	Address  string `json:"address"`
	Facility string `json:"facility"`
	Tag      string `json:"tag"`
	// contains filtered or unexported fields
}

func (*SyslogWriter) Destroy

func (sw *SyslogWriter) Destroy()

func (*SyslogWriter) Flush

func (sw *SyslogWriter) Flush()

func (*SyslogWriter) Init

func (sw *SyslogWriter) Init(config string) error

func (*SyslogWriter) WriteMsg

func (sw *SyslogWriter) WriteMsg(msg string, skip int, level LogLevel) error

Jump to

Keyboard shortcuts

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