File: log.go

package info (click to toggle)
golang-github-evilsocket-islazy 1.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 292 kB
  • sloc: javascript: 8; makefile: 3
file content (43 lines) | stat: -rw-r--r-- 979 bytes parent folder | download
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
37
38
39
40
41
42
43
package main

import (
	"github.com/evilsocket/islazy/log"
)

func main() {
	// equivalent to log.Output = ""
	log.Output = "/dev/stdout"
	log.Level = log.DEBUG
	log.OnFatal = log.NoneOnFatal
	log.DateFormat = "06-Jan-02"
	log.TimeFormat = "15:04:05"
	log.DateTimeFormat = "2006-01-02 15:04:05"
	log.Format = "{datetime} {level:color}{level:name}{reset} {message}"
	log.Callback = func(verbosity log.Verbosity, message string) {
		// fmt.Printf("got message '%s'\n", message)
	}

	if err := log.Open(); err != nil {
		panic(err)
	}
	defer log.Close()

	log.Raw("hello world")
	log.Debug("hello world")
	log.Info("hello world")
	log.Important("hello world")
	log.Warning("hello world")
	log.Error("hello world")
	log.Fatal("hello world")

	log.OnFatal = log.ExitOnFatal
	log.NoEffects = true

	log.Raw("hello world")
	log.Debug("hello world")
	log.Info("hello world")
	log.Important("hello world")
	log.Warning("hello world")
	log.Error("hello world")
	log.Fatal("hello world")
}