Categorygithub.com/chasex/glog
modulepackage
0.0.0-20160217080310-c62392af379c
Repository: https://github.com/chasex/glog.git
Documentation: pkg.go.dev

# README

glog

Package glog implements a simple level logging package based on golang's standard log and glog package. It has fully compatible interface to standard log package. It defines a type, Logger, with methods for formatting output.

Basic examples:

options := glog.LogOptions{
	File: "./abc.log",
	Flag: glog.LstdFlags,
	Level: glog.Ldebug,
	Mode: glog.R_None,
}
logger, err := glog.New(options)
if err != nil {
	panic(err)
}
logger.Debug("hello world")
logger.Infof("hello, %s", "chasex")
logger.Warn("testing message")
logger.Flush()

The output contents in abc.log will be:

2016/02/16 17:50:07 DEBUG hello world
2016/02/16 17:50:07 INFO hello, chasex
2016/02/16 17:50:07 WARN testing message

It also support rotating log file by size, hour or day. According to rotate mode, log file name has distinct suffix:

R_None: no suffix, just base name, abc.log.
R_Size: suffix with date and clock, abc.log-YYYYMMDD-HHMMSS.
R_Hour: suffix with date and hour, abc.log-YYYYMMDD-HH.
R_Day:  suffix with date, abc.log-YYYYMMDD.

Note that it has a daemon routine flushing buffered data to underlying file periodically (default every 30s). When exit, remember calling Flush() manually, otherwise it may cause some date loss.

For more details see document: https://godoc.org/github.com/chasex/glog

# Packages

No description provided by the author

# Functions

New creates a new Logger.

# Constants

the date in the local time zone: 2009/01/23.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
log entry level: DEBUG, INFO, ...
full file name and line number: /a/b/c/d.go:23.
microsecond resolution: 01:23:23.123123.
No description provided by the author
final file name element and line number: d.go:23.
standard prefix.
no prefix.
the time in the local time zone: 01:23:23.
if Ldate or Ltime is set, use UTC rather than the local time zone.
No description provided by the author
Rotate file by day.
Rotate file by hour.
Never rotate.
Rotate file by size.

# Structs

A Logger represents an active logging object that generates lines of output to an io.Writer.
LogOptions control logger's behaviour.

# Type aliases

Level defines each log entry's level of verbosity.
RotateMode defines log file's rotating mode.