Documentation ¶
Index ¶
- Constants
- Variables
- type FastLog
- type Line
- func (l *Line) Bool(name string, value bool) *Line
- func (l *Line) ByteArray(name string, value []byte) *Line
- func (l *Line) Bytes(name string, value []byte) *Line
- func (l *Line) Duration(name string, duration time.Duration) *Line
- func (l *Line) Error(value error) *Line
- func (l *Line) IP(name string, value netip.Addr) *Line
- func (l *Line) IPArray(name string, value []net.IP) *Line
- func (l *Line) IPSlice(name string, value net.IP) *Line
- func (l *Line) Int(name string, value int) *Line
- func (l *Line) LF() *Line
- func (l *Line) Label(name string) *Line
- func (l *Line) MAC(name string, value net.HardwareAddr) *Line
- func (l *Line) Module(name string, msg string) *Line
- func (l *Line) Sprintf(name string, value interface{}) *Line
- func (l *Line) String(name string, value string) *Line
- func (l *Line) StringArray(name string, value []string) *Line
- func (l *Line) Stringer(value fmt.Stringer) *Line
- func (l *Line) Struct(value FastLog) *Line
- func (l *Line) Time(name string, t time.Time) *Line
- func (l *Line) ToString() string
- func (l *Line) Uint16(name string, value uint16) *Line
- func (l *Line) Uint16Hex(name string, value uint16) *Line
- func (l *Line) Uint32(name string, value uint32) *Line
- func (l *Line) Uint8(name string, value uint8) *Line
- func (l *Line) Uint8Hex(name string, value uint8) *Line
- func (l *Line) Write() error
- type LogLevel
- type Logger
- func (l *Logger) Disable()
- func (l *Logger) EnableDebug()
- func (l *Logger) EnableInfo()
- func (l *Logger) IsDebug() bool
- func (l *Logger) IsInfo() bool
- func (l *Logger) Level() LogLevel
- func (logger *Logger) Msg(msg string) *Line
- func (l *Logger) SetLevel(level LogLevel)
- func (l *Logger) SetLevelString(str string)
Constants ¶
const ( LevelInvalid = LogLevel(0) LevelError = LogLevel(1) LevelInfo = LogLevel(2) LevelDebug = LogLevel(3) )
Variables ¶
var DefaultIOWriter io.Writer = os.Stderr
DefaultIOWriter keep package io writer to msg output
Functions ¶
This section is empty.
Types ¶
type Line ¶
type Line struct {
// contains filtered or unexported fields
}
Line contains the internal buffer to be written to the input socket.
func (*Line) MAC ¶
func (l *Line) MAC(name string, value net.HardwareAddr) *Line
MAC appends a mac address to the line
func (*Line) StringArray ¶
StringArray appends an array of strings to the line
func (*Line) Stringer ¶
Stringer appends a string to the line. This requires introspection and should seldome be used. It is a convenient function to log unknown data types that implemt the Stringer interface.
func (*Line) Struct ¶
Struct appends a struct to the line. the struct must implement the FasLog interface
func (*Line) ToString ¶
ToString converts the line to string and return the line to the pool. The line buffer is no longer available after calling this function.
type LogLevel ¶
type LogLevel uint32
LogLevel is type to hold the log level
func Str2LogLevel ¶
Str2LogLevel converts a string to a LogLevel. Valid strings are: error, info, debug If the string is invalid, the function returns LevelError
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a handler to access logging functions. The typical way is to instantiate a Logger variable for the package and log messages via Msg(). Example:
var Logger = New("package") func test() { Logger.Msg("hello world").Write() }
func (*Logger) EnableDebug ¶
func (l *Logger) EnableDebug()
func (*Logger) EnableInfo ¶
func (l *Logger) EnableInfo()
func (*Logger) Msg ¶
Msg allocates a new line and appends msg to it.
Msg() allocates an underlying buffer from the buffer pool and appends the msg to it. Msg() does not write the buffer. The caller must call Write() or ToString() to write the line and free the underlying buffer to the buffer pool. for example:
l := New("mypackage").Msg("Hello world").Int("mynumber", 1) l.Write() or l.ToString()