Documentation ¶
Overview ¶
Package daslog is a simple logger package.
Explanation of the name: DAmn Simple LOGger.
Simple example:
func main() { o := daslog.Options{ Destination: os.Stdout, Prefix: "{{.O}} [{{.Q}}]: ", LogLevel: daslog.UrgencyLevelCritical, } l, err := daslog.New(o) if err != nil { fmt.Print(err) return } l.Log(daslog.UrgencyLevelNotice, "test notice message") l.Info("test info message") l.Errorf("%s %s %s", "test", "error", "message") }
Output:
2016-01-04 21:16:41 [notice]: test notice message 2016-01-04 21:16:41 [info]: test info message 2016-01-04 21:16:42 [error]: test error message
Index ¶
- type Daslog
- func (l *Daslog) Critical(message string)
- func (l *Daslog) Criticalf(message string, a ...interface{})
- func (l *Daslog) Error(message string)
- func (l *Daslog) Errorf(message string, a ...interface{})
- func (l *Daslog) Info(message string)
- func (l *Daslog) Infof(message string, a ...interface{})
- func (l *Daslog) Log(urgencyLevel UrgencyLevel, message string)
- func (l *Daslog) Logf(urgencyLevel UrgencyLevel, message string, a ...interface{})
- func (l *Daslog) Notice(message string)
- func (l *Daslog) Noticef(message string, a ...interface{})
- type LogHandler
- type Options
- type UrgencyLevel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Daslog ¶
type Daslog struct {
// contains filtered or unexported fields
}
Daslog - main struct.
func (*Daslog) Log ¶
func (l *Daslog) Log(urgencyLevel UrgencyLevel, message string)
Log - print message to log.
func (*Daslog) Logf ¶
func (l *Daslog) Logf(urgencyLevel UrgencyLevel, message string, a ...interface{})
Logf - print message to log in printf style :)
type LogHandler ¶
type LogHandler func(urgencyLevel UrgencyLevel, message string)
LogHandler - log handler type.
type Options ¶
type Options struct { // LogLevel provides the opportunity to choose the level of // information messages. // Each level includes the messages from the previous level. // UrgencyLevelNone - no messages // 0 // UrgencyLevelNotice - notice // 1 // UrgencyLevelInfo - info // 2 // UrgencyLevelError - error // 3 // UrgencyLevelCritical - critical // 4 // // Default: 'UrgencyLevelNone'. LogLevel UrgencyLevel // Prefix provides the ability to add prefix text to all log messages. // In addition, you can use commands to display the date and time (these // format commands are based on the linux 'GNU date' format syntax). // // 'GNU date' compatible format commands: // // {{.F}} - full date (2016-01-04) // {{.T}} - time (16:52:36) // {{.r}} - 12-hour clock time (11:11:04 PM) // // {{.Y}} - year (2016) // {{.y}} - last two digits of year (00..99) // {{.m}} - month (01..12) // {{.b}} - locale's abbreviated month name (Jan) // {{.B}} - locale's full month name (January) // {{.d}} - day of month (01) // {{.a}} - locale's abbreviated weekday name (Sun) // {{.A}} - locale's full weekday name (Sunday) // {{.H}} - 24-hour clock hour (00..23) // {{.I}} - 12-hour clock hour (01..12) // {{.M}} - minute (00..59) // {{.S}} - second (00..60) // {{.p}} - locale's equivalent of either AM or PM (AM) // // Incompatible format commands: // // {{.O}} - same as {{.F}} + {{.T}} (2016-01-04 16:52:36) // {{.Q}} - message urgency level (info, critical, etc) Prefix string // Destination provides the opportunity to choose the own // destination for log messages (errors, info, etc). // // Default: 'os.Stdout'. Destination io.Writer // Destinations provides the opportunity to choose several destinations // for delivery of log messages. // // If 'Destinations' is selected - 'Destination' will be ignored. Destinations []io.Writer // LogHandler takes a log messages to bypass the internal // mechanism of the message processing. // // If LogHandler is selected - all log settings will be ignored. Handler LogHandler }
Options - struct, which is used to configure a Daslog.
type UrgencyLevel ¶
type UrgencyLevel int
UrgencyLevel - declare the level of informativity of log message.
const ( UrgencyLevelNone UrgencyLevel = iota UrgencyLevelNotice UrgencyLevelInfo UrgencyLevelError UrgencyLevelCritical )
predefined UrgencyLevel levels
Click to show internal directories.
Click to hide internal directories.