Documentation ¶
Index ¶
- Variables
- func Colors(b bool)
- func CommitSd(sl *Slog)
- func DebugInfo()
- func Error(vals ...interface{})
- func Errorf(str string, vals ...interface{})
- func Errorln(vals ...interface{})
- func Exiter(fn func(int)) error
- func FallbackFormater(sl *Slog) ([]byte, error)
- func Fatal(vals ...interface{})
- func Fatalf(s string, vals ...interface{})
- func Fatalln(vals ...interface{})
- func FormatTime(buf *[]byte, t time.Time)
- func GoPanic(r interface{}, stack []byte, cont bool)
- func Itoa(buf *[]byte, i int, wid int)
- func JSON(l *Slog) ([]byte, error)
- func NoDebugInfo()
- func Panic(vals ...interface{})
- func Panicf(s string, vals ...interface{})
- func Panicln(vals ...interface{})
- func Print(vals ...interface{})
- func Printf(str string, vals ...interface{})
- func Println(vals ...interface{})
- func Prior2Sd(level Level) systemd.Priority
- func Recover(notexit bool)
- func SdFormater(sl *Slog) ([]byte, error)
- func SetLevel(level Level) error
- func SetOutput(domain string, level Level, w io.WriteCloser, commiter func(sl *Slog), ...) error
- func Testing(t bool)
- type Level
- type Log
- type Logger
- type Slog
- func (l *Slog) Close() error
- func (l *Slog) Colors(b bool) *Slog
- func (l *Slog) DebugLevel() *Slog
- func (l *Slog) Di() *Slog
- func (l *Slog) Error(v ...interface{})
- func (l *Slog) ErrorLevel() *Slog
- func (l *Slog) Errorf(s string, v ...interface{})
- func (l *Slog) Errorln(v ...interface{})
- func (l *Slog) Fatal(v ...interface{})
- func (l *Slog) Fatalf(s string, v ...interface{})
- func (l *Slog) Fatalln(v ...interface{})
- func (l *Slog) GoPanic(r interface{}, stack []byte, cont bool)
- func (l *Slog) InfoLevel() *Slog
- func (l *Slog) Init(domain string, nl int) error
- func (l *Slog) MakeDefault() *Slog
- func (l *Slog) NoDi() *Slog
- func (l *Slog) Panic(v ...interface{})
- func (l *Slog) Panicf(s string, v ...interface{})
- func (l *Slog) Panicln(v ...interface{})
- func (l *Slog) Print(v ...interface{})
- func (l *Slog) Printf(s string, v ...interface{})
- func (l *Slog) Println(v ...interface{})
- func (l *Slog) ProtoLevel() *Slog
- func (l *Slog) SetLevel(level Level) *Slog
- func (l *Slog) Tag(tags ...string) *Slog
- func (l *Slog) Write(p []byte) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
var ( // GID is process group ID GID string // UID is process user ID UID string // PID is process group ID PID string // Hostname is the hostname where the process is running Hostname string )
var BufferSize = 512
BufferSize is the initial allocated size of the buffers.
var Pool *sync.Pool
Pool of buffers to be used with formatter and commit functions.
var RecoverBufferStack = 4096
RecoverBufferStack amount of buffer to store the stack.
Functions ¶
func FallbackFormater ¶
FallbackFormater is called if systemd isn't available. Need to set Writter in Slog struct.
func Fatal ¶
func Fatal(vals ...interface{})
Fatal print a log entry to the destine and exit with 1.
func Fatalf ¶
func Fatalf(s string, vals ...interface{})
Fatalf print a formated log entry to the destine and exit with 1.
func Fatalln ¶
func Fatalln(vals ...interface{})
Fatalln print a log entry to the destine and exit with 1.
func FormatTime ¶
FormatTime is a sample function for format the data and time.
func Itoa ¶
Itoa converts a int to a byte. i is the interger to be converted, buf is a pointer to the buffer that will receive the converted interger and wid is the number of digits, if the digits is less than wid it will be filled with zeros. This function come from std.
func Panicf ¶
func Panicf(s string, vals ...interface{})
Panicf print a formated log entry to the destine and call panic.
func Panicln ¶
func Panicln(vals ...interface{})
Panicln print a log entry to the destine and call panic.
func Print ¶
func Print(vals ...interface{})
Print prints a log entry to the destine, this is determined by the commit function.
func Printf ¶
func Printf(str string, vals ...interface{})
Printf prints a formated log entry to the destine.
func Recover ¶
func Recover(notexit bool)
Recover from panic and log the stack. If notexit is false, call l.Exiter(1), if not continue.
func SdFormater ¶
SdFormater format the mensagem for systemd journal
Types ¶
type Level ¶
type Level uint8
Level type represents a log level.
const ( ProtoPrio Level = iota + 1 //More priority DebugPrio InfoPrio ErrorPrio FatalPrio PanicPrio NoPrio //Less priority )
This constants defines the levels available to the logger.
func ParseLevel ¶
ParseLevel parses the string form of a level to the type Level.
type Log ¶
type Log struct { Domain []byte Priority Level Timestamp time.Time Tags *tags DiLevel int DoDi bool // contains filtered or unexported fields }
Log is a simple log entry.
func (*Log) FormatMessage ¶
FormatMessage simple format the message without color.
func (*Log) SetTimeZone ¶
func (l *Log) SetTimeZone()
SetTimeZone sets the zone info from time.Now()
type Logger ¶
type Logger interface { Print(...interface{}) Printf(string, ...interface{}) Println(...interface{}) Fatal(...interface{}) Fatalf(string, ...interface{}) Fatalln(...interface{}) Panic(...interface{}) Panicf(string, ...interface{}) Panicln(...interface{}) }
Logger defines a interface to the basic logger functions.
type Slog ¶
type Slog struct { // Level is the max log level that will filter the entries. Level Level // Filter filter the log entry. If return true the log entry pass the filter. Filter func(l *Slog) bool // Format a readable message from the log information Formatter func(l *Slog) ([]byte, error) // Commit sent entry to somewhere. Commit func(l *Slog) // Writer can be a destiny in the Commit function. Writter io.WriteCloser // Log entry. Log *Log // Exiter is the function called on Fatal and Panic methods. Exiter func(int) Lck *sync.Mutex Cp bool // contains filtered or unexported fields }
Slog is the logger.
func DefaultLogger ¶
func DefaultLogger() *Slog
DefaultLogger return the default logger. Mainly to be used with Writer interface.
func (*Slog) Fatal ¶
func (l *Slog) Fatal(v ...interface{})
Fatal print a log entry to the destine and exit with 1.
func (*Slog) Fatalln ¶
func (l *Slog) Fatalln(v ...interface{})
Fatalln print a log entry to the destine and exit with 1.
func (*Slog) Init ¶
Init initializes the logger with domain and numLogs. numLogs is the number of Slog struct in the pool.
func (*Slog) MakeDefault ¶
MakeDefault turn the behavior of actual chain of functions into default to be used in the next chain.
func (*Slog) Panic ¶
func (l *Slog) Panic(v ...interface{})
Panic print a log entry to the destine and call panic.
func (*Slog) Panicln ¶
func (l *Slog) Panicln(v ...interface{})
Panicln print a log entry to the destine and call panic.
func (*Slog) Print ¶
func (l *Slog) Print(v ...interface{})
Print prints a log entry to the destine, this is determined by the commit function.
func (*Slog) Println ¶
func (l *Slog) Println(v ...interface{})
Println prints a log entry to the destine.
func (*Slog) ProtoLevel ¶
ProtoLevel set the log level to protocol