Documentation ¶
Overview ¶
slog is a micro log libray.log format is use default. log use ConsolePrinter as default(at level DEBUG) ,you can use it without any configuration.
in advance,use cmdline args configure you output mode and other options.once operated the default console printer is no longer exist.so add it if needed.
-logmode=stdout:info,file:warn -logf_dir=. -logf_name=app -logf_ksize=10 -logf_blockmillis=200 -logf_bufferrow=123 -logf_backup=5
or you can set up by code:
flag.Set("logmode", "stdout:error,file:debug") //flag.Set("logmode", "stdout:verbo,file:fatal") slog.InitByFlags()
Attention: anywhere you must call InitByFlags.(we support setup by code which made me don't known when flags is ready ). And slog's file output use one goroutine,it not worth to support flush file by hand which means a lock is needed. if you want guarantee all log flush to file before exit,I suggest just wait for a few second .
Index ¶
- Constants
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Default() *logger
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Exit(args ...interface{})
- func Exitf(format string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func InitByFlags()
- func New(lv lev, p Printer) *logger
- func Note(args ...interface{})
- func Notef(format string, args ...interface{})
- func Verbose(args ...interface{})
- func Verbosef(format string, args ...interface{})
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- type Console
- type DefaultFormater
- type FilePrinter
- type Formater
- type Printer
- type UdpPrinter
Constants ¶
View Source
const ( LevDEBUG lev = 1 LevVERBOSE lev = 2 LevINFO lev = 4 LevWARN lev = 8 LevERROR lev = 0x10 LevNOTE lev = 0x20 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DefaultFormater ¶
type DefaultFormater struct { }
type FilePrinter ¶
type FilePrinter struct {
// contains filtered or unexported fields
}
func (*FilePrinter) Print ¶
func (this *FilePrinter) Print(s *string) error
type Printer ¶
type UdpPrinter ¶
type UdpPrinter struct {
// contains filtered or unexported fields
}
func (*UdpPrinter) Print ¶
func (this *UdpPrinter) Print(s *string) error
Click to show internal directories.
Click to hide internal directories.