-
Notifications
You must be signed in to change notification settings - Fork 2
/
compat.go
69 lines (57 loc) · 1.87 KB
/
compat.go
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright 2013 Marc Weistroff. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
package log
import (
"fmt"
"os"
)
var stdFormatter = &LineFormatter{LineFormat: "%datetime% %level_name%: %message%"}
var stdHandler = &writeCloserHandler{wc: os.Stderr, Handler: &Handler{Level: DEBUG, Formatter: stdFormatter}}
var DefaultLogger = &Logger{Name: "", handlers: []HandlerInterface{stdHandler}, processors: []Processor{}}
// Fatal is equivalent to a call to Print followed by a call to os.Exit(1)
func Fatal(v ...interface{}) {
Print(v)
os.Exit(1)
}
// Fatal is equivalent to a call to Printf followed by a call to os.Exit(1)
func Fatalf(format string, v ...interface{}) {
Printf(format, v)
os.Exit(1)
}
// Fatalln is equivalent to a call to Println followed by a call to os.Exit(1)
func Fatalln(v ...interface{}) {
Println(v)
os.Exit(1)
}
// Panic is equivalent to a call to Print followed by a call to panic
func Panic(v ...interface{}) {
s := fmt.Sprint(v)
Print(s)
panic(s)
}
// Panicf is equivalent to a call to Printf followed by a call to panic
func Panicf(format string, v ...interface{}) {
s := fmt.Sprintf(format, v...)
Print(s)
panic(s)
}
// Panicln is equivalent to a call to Println followed by a call to panic
func Panicln(v ...interface{}) {
s := fmt.Sprintln(v...)
Print(s)
panic(s)
}
// Print calls Debug in an instance of Logger where the only handler outputs to Stderr
func Print(v ...interface{}) {
DefaultLogger.Debug(v...)
}
// Printf calls Debug in an instance of Logger where the only handler outputs to Stderr
// Arguments are handled in the manner of fmt.Printf.
func Printf(format string, v ...interface{}) {
DefaultLogger.Debug(fmt.Sprintf(format, v...))
}
// Arguments are handled in the manner of fmt.Println.
func Println(v ...interface{}) {
DefaultLogger.Debug(fmt.Sprintln(v...))
}