# README
log4go
Please see http://log4go.googlecode.com/ for more log4go usages. My personal package (github.com/AlexStocks/goext/log) wrappered log4go functions further more which provides the most powerful log4go.
Installation:
- Run
go get -u -v github.com/AlexStocks/log4go
Usage:
- Add the following import:
import l4g "github.com/AlexStocks/log4go"
func main() {
defer l4g.Close() // to close l4g.Global
}
get logger
Global logger
import l4g "github.com/alecthomas/log4go"
l4g.Info("hello world")
defer l4g.Close()
NewDefaultLogger
log := l4g.NewDefaultLogger(l4g.INFO)
log.Info("hello world")
defer log.Close()
l4g.Logger
log := make(l4g.Logger)
defer log.Close()
log.AddFilter("stdout", l4g.DEBUG, l4g.NewConsoleLogWriter())
log.Info("hello world")
output log
l4g.Finest()
l4g.Fine()
l4g.Debug()
l4g.Trace()
l4g.Info()
l4g.Warning()
l4g.Error()
l4g.Critical()
UserGuide
Level
FINEST
FINE
DEBUG
TRACE
INFO
WARNING
ERROR
CRITICAL
Feature list:
- Output colorful terminal log string by log level
- Output json log
- Add maxbackup choice in examples.xml to delete out of date log file
- Output escape query string safety
- Add filename to every log line
- Create log path if log path does not exist
- Add caller option to let log4go do not output file/function-name/line-number
- Add %P to output process ID
- Rotate log file daily/hourly
- Support json/xml/yml configuration file
# Packages
No description provided by the author
# Functions
Wrapper for (*Logger).AddFilter.
Wrapper for (*Logger).Close (closes and removes all logwriters).
No description provided by the author
No description provided by the author
Logs the given message and crashes the program.
Utility for critical log messages (returns an error for easy function returns) (see Debug() for parameter explanation) These functions will execute a closure exactly once, to build the error message for the return Wrapper for (*Logger).Critical.
Utility for debug log messages When given a string as the first argument, this behaves like Logf but with the DEBUG log level (e.g.
Utility for error log messages (returns an error for easy function returns) (see Debug() for parameter explanation) These functions will execute a closure exactly once, to build the error message for the return Wrapper for (*Logger).Error func Error(arg0 interface{}, args ...interface{}) error {.
Compatibility with `log`.
Compatibility with `log`.
Utility for fine log messages (see Debug() for parameter explanation) Wrapper for (*Logger).Fine.
Utility for finest log messages (see Debug() for parameter explanation) Wrapper for (*Logger).Finest.
Known format codes: %T - Time (15:04:05 MST) %t - Time (15:04) %D - Date (2006/01/02) %d - Date (01/02/06) %L - Level (FNST, FINE, DEBG, TRAC, WARN, EROR, CRIT) %P - Pid of process %S - Source %M - Message Ignores unknown formats Recommended: "[%D %T] [%L] (%S) %M".
Utility for info log messages (see Debug() for parameter explanation) Wrapper for (*Logger).Info.
Wrapper for (*Logger).LoadConfiguration.
Send a log message manually Wrapper for (*Logger).Log.
Send a closure log message Wrapper for (*Logger).Logc.
Send a formatted log message easily Wrapper for (*Logger).Logf.
Create a new logger with a "stdout" filter configured to send log messages at or above lvl to standard output.
This creates a new ConsoleLogWriter.
Create a new logger with a "stdout" filter configured to send log messages at or above lvl to standard output.
NewFileLogWriter creates a new LogWriter which writes to the given file and has rotation enabled if rotate is true and set a memory alignment buffer if bufSize is non-zero.
This creates a new FormatLogWriter.
Create a new logger.
No description provided by the author
NewXMLLogWriter is a utility method for creating a FileLogWriter set up to output XML record log messages instead of line-based ones.
SetCallerFlag enable/disable output caller info (file/func/line).
No description provided by the author
SetLogLevel changes default logger's log level.
No description provided by the author
Compatibility with `log`.
Compatibility with `log`.
Compatibility with `log`.
Compatibility with `log`.
No description provided by the author
Utility for trace log messages (see Debug() for parameter explanation) Wrapper for (*Logger).Trace.
Utility for warn log messages (returns an error for easy function returns) (see Debug() for parameter explanation) These functions will execute a closure exactly once, to build the error message for the return Wrapper for (*Logger).Warn func Warn(arg0 interface{}, args ...interface{}) error {.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
rotate file suffix.
No description provided by the author
***** Constants ******/.
***** Constants ******/.
No description provided by the author
No description provided by the author
No description provided by the author
[level] message.
[时:分:秒 年月日] [level] (class:file:line) message.
[小时:分钟 年月日] [level] message.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Version information.
Version information.
Version information.
Version information.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
Bright colors.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
LogBufferLength specifies how many log messages a particular log4go logger can buffer at a time before writing them.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Normal colors NORMAL = []byte{'\033', '0', 'm'}.
No description provided by the author
No description provided by the author
No description provided by the author
***** Variables ******/.
100ms.
No description provided by the author
# Structs
No description provided by the author
This is the standard writer that prints to standard output.
This log writer sends output to a file.
A Filter represents the log level below which no log records are written to the associated LogWriter.
This is the standard writer that prints to standard output.
***** LogCloser ******/.
A Logger represents a collection of Filters through which log messages are written.
A LogRecord contains all of the pertinent information for each message.
This log writer sends output to a socket.
# Interfaces
This is an interface for anything that should be able to write logs.