modulepackage
0.0.0-20250228104026-aa952e427460
Repository: https://github.com/lrita/log.git
Documentation: pkg.go.dev
# README
log
It is a logger for golang, which has met many of my needs. It cat set different formatter with the same appender. Also it can set multi-appender for a logger instance.
All the new logger inherited the global logger. If the new logger is not set the formatter or appender, it will inherited the global logger's formatter and appender.
Level
This logger has 6 log-level.
FATAL
ERROR
INFO
WARN
DEBUG
TRACE
We can use the SetLevel
or Logger.SetLevel
to chang the log-level for each logger instance.
Fomatter
We can set a format layout to the each level for the logger instance. The global logger default
format layout is %F %T [%l] %m
. The pattern is:
%m => the log message and its arguments formatted with `fmt.Sprintf` or `fmt.Sprint`
%l => the log-level string
%C => the caller with full file path
%c => the caller with short file path
%L => the line number of caller
%% => '%'
%n => '\n'
%F => the date formatted like "2006-01-02"
%D => the date formatted like "01/02/06"
%T => the time formatted like 24h style "15:04:05"
%a => the short name of weekday like "Mon"
%A => the full name of weekday like "Monday"
%b => the short name of month like "Jan"
%B => the full name of month like "January"
%d => the datetime formatted like RFC3339 "2006-01-02T15:04:05Z07:00"
Install
go get -u github.com/lrita/log
# Functions
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
IsDebugEnabled indicates whether debug level is enabled.
New return a sub logger of global logger.
NewAIO returns a new Writer whose buffer has at least the specified size.
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
SetAppender set append for global logger.
SetCallDepth set callee stack depth.
SetFormat set format-string for global logger.
SetLevel log level for global logger.
SetRatelimit set log rate limit for global logger.
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
No description provided by the author
ExitOnFatal decides whether or not to exit when fatal log printing.
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
AIO implements buffering asynchronous Writer for an io.Writer object.
No description provided by the author
# Type aliases
No description provided by the author