Documentation ¶
Overview ¶
Package logging implements log library for other applications. It provides functions Debug, Info, Warning, Error, Critical, and formatting version Logf.
Example:
logger := logging.SimpleLogger("main") logger.SetLevel(logging.WARNING) logger.Error("test for error") logger.Warning("test for warning", "second parameter") logger.Debug("test for debug")
Index ¶
- Constants
- func GetGoID() int32
- func GetLevelName(levelValue Level) string
- type Level
- type Logger
- func BasicLogger(name string) (*Logger, error)
- func ConfigLogger(filename string) (*Logger, error)
- func FileLogger(name string, level Level, format string, timeFormat string, file string, ...) (*Logger, error)
- func RichLogger(name string) (*Logger, error)
- func SimpleLogger(name string) (*Logger, error)
- func WriterLogger(name string, level Level, format string, timeFormat string, out io.Writer, ...) (*Logger, error)
- func (logger *Logger) Critical(v ...interface{})
- func (logger *Logger) Criticalf(format string, v ...interface{})
- func (logger *Logger) Debug(v ...interface{})
- func (logger *Logger) Debugf(format string, v ...interface{})
- func (logger *Logger) Destroy()
- func (logger *Logger) Error(v ...interface{})
- func (logger *Logger) Errorf(format string, v ...interface{})
- func (logger *Logger) Fatal(v ...interface{})
- func (logger *Logger) Fatalf(format string, v ...interface{})
- func (logger *Logger) Flush()
- func (logger *Logger) Info(v ...interface{})
- func (logger *Logger) Infof(format string, v ...interface{})
- func (logger *Logger) Level() Level
- func (logger *Logger) Log(level Level, v ...interface{})
- func (logger *Logger) Logf(level Level, format string, v ...interface{})
- func (logger *Logger) Name() string
- func (logger *Logger) Notset(v ...interface{})
- func (logger *Logger) Notsetf(format string, v ...interface{})
- func (logger *Logger) RecordArgs() []string
- func (logger *Logger) RecordFormat() string
- func (logger *Logger) SetLevel(level Level)
- func (logger *Logger) SetWriter(out ...io.Writer)
- func (logger *Logger) StartTime() int64
- func (logger *Logger) Sync() bool
- func (logger *Logger) TimeFormat() string
- func (logger *Logger) Warn(v ...interface{})
- func (logger *Logger) Warnf(format string, v ...interface{})
- func (logger *Logger) Warning(v ...interface{})
- func (logger *Logger) Warningf(format string, v ...interface{})
- func (logger *Logger) Writer() io.Writer
Constants ¶
const ( BasicFormat = "%s [%6s] %30s - %s\n name,levelname,time,message" RichFormat = "%s [%6s] %d %30s - %d - %s:%s:%d - %s\n name, levelname, seqid, time, thread, filename, funcname, lineno, message" )
pre-defined formats
const ( DefaultFileName = "logging.log" // default logging filename DefaultConfigFile = "logging.conf" // default logging configuration file DefaultTimeFormat = "2006-01-02 15:04:05.999999999" // defaulttime format )
Pre-defined formats
Variables ¶
This section is empty.
Functions ¶
func GetGoID ¶
func GetGoID() int32
GetGoID returns the id of goroutine, which is defined in ./get_go_id.c
func GetLevelName ¶
GetLevelName lets users be able to get level name from level value.
Types ¶
type Level ¶
type Level int32
Level is the type of level.
const ( CRITICAL Level = 50 FATAL Level = CRITICAL ERROR Level = 40 WARNING Level = 30 WARN Level = WARNING INFO Level = 20 DEBUG Level = 10 NOTSET Level = 0 )
Values of level
func GetLevelValue ¶
GetLevelValue lets users be able to get level value from level name.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is the logging struct.
func BasicLogger ¶
BasicLogger creates a new logger with basic configuration.
func ConfigLogger ¶
WriterLogger creates a new logger from a configuration file
func FileLogger ¶
func FileLogger(name string, level Level, format string, timeFormat string, file string, sync bool) (*Logger, error)
FileLogger creates a new logger with file output.
func RichLogger ¶
RichLogger creates a new logger with simple configuration.
func SimpleLogger ¶
SimpleLogger creates a new logger with simple configuration.
func WriterLogger ¶
func WriterLogger(name string, level Level, format string, timeFormat string, out io.Writer, sync bool) (*Logger, error)
WriterLogger creates a new logger with a writer
func (*Logger) Destroy ¶
func (logger *Logger) Destroy()
Destroy sends quit signal to watcher and releases all the resources.
func (*Logger) Log ¶
Logln receives log request from the client. The request includes a set of variables.
func (*Logger) Logf ¶
Logf receives log request from the client. The request has a string parameter to describe the format of output.