-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathexample.go
More file actions
36 lines (32 loc) · 902 Bytes
/
example.go
File metadata and controls
36 lines (32 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"os"
"github.com/apsdehal/go-logger"
)
func main () {
// Get the instance for logger class
// Third option is optional and is instance of type io.Writer, defaults to os.Stderr
log, err := logger.New("test", 1, os.Stdout)
if err != nil {
panic(err) // Check for error
}
// Critically log critical
log.Critical("This is Critical!")
// Debug
log.Debug("This is Debug!")
// Give the Warning
log.Warning("This is Warning!")
// Show the error
log.Error("This is Error!")
// Notice
log.Notice("This is Notice!")
// Show the info
log.Info("This is Info!")
// Show warning with format message
log.SetFormat("[%{module}] [%{level}] %{message}")
log.Warning("This is Warning!")
// Also you can set your format as default format for all new loggers
logger.SetDefaultFormat("%{message}")
log2, _ := logger.New("pkg", 1, os.Stdout)
log2.Error("This is Error!")
}