-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.go
72 lines (59 loc) · 3.11 KB
/
log.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
70
71
72
// Package log provides structured and unstructured logging functions
package log
import (
"github.com/thehungry-dev/cog"
"github.com/thehungry-dev/cog/handler"
"github.com/thehungry-dev/cog/message/field"
"github.com/thehungry-dev/cog/settings"
)
var Private field.Builder
var fields field.Builder
var Default cog.Writer
var JSON cog.Writer
func String(name string, value string) field.Field { return fields.String(name, value) }
func Int64(name string, value int64) field.Field { return fields.Int64(name, value) }
func Int(name string, value int) field.Field { return fields.Int(name, value) }
func Int32(name string, value int32) field.Field { return fields.Int32(name, value) }
func Int16(name string, value int16) field.Field { return fields.Int16(name, value) }
func Int8(name string, value int8) field.Field { return fields.Int8(name, value) }
func Bool(name string, value bool) field.Field { return fields.Bool(name, value) }
func Complex128(name string, value complex128) field.Field { return fields.Complex128(name, value) }
func Complex64(name string, value complex64) field.Field { return fields.Complex64(name, value) }
func Float64(name string, value float64) field.Field { return fields.Float64(name, value) }
func Float32(name string, value float32) field.Field { return fields.Float32(name, value) }
func Nil(name string, value interface{}) field.Field { return fields.Nil(name, value) }
func Object(name string, value interface{}) field.Field { return fields.Object(name, value) }
func Array(name string, value interface{}) field.Field { return fields.Array(name, value) }
func Tags(tags ...string) cog.Writer { return Default.Tags(tags...) }
func Data(fields ...field.Field) cog.Writer { return Default.Data(fields...) }
func Trace(body string) { Default.Trace(body) }
func Tracef(f string, a ...interface{}) { Default.Tracef(f, a...) }
func Debug(body string) { Default.Debug(body) }
func Debugf(f string, a ...interface{}) { Default.Debugf(f, a...) }
func Info(body string) { Default.Info(body) }
func Infof(f string, a ...interface{}) { Default.Infof(f, a...) }
func Warn(body string) { Default.Warn(body) }
func Warnf(f string, a ...interface{}) { Default.Warnf(f, a...) }
func Error(body string) { Default.Error(body) }
func Errorf(f string, a ...interface{}) { Default.Errorf(f, a...) }
func Fatal(body string) { Default.Fatal(body) }
func Fatalf(f string, a ...interface{}) { Default.Fatalf(f, a...) }
func init() {
Private = field.Builder{Private: true}
set := settings.Getenv()
device := set.Device()
var handlers []handler.Handler
var outputHandler handler.Handler
handlers = set.Filters()
outputHandler = set.OutputHandler()
handlers = append(handlers, outputHandler)
Default = cog.With(
handler.BuildPipe(handlers...),
)
handlers = set.Filters()
outputHandler = handler.BuildOutput(device, handler.OutputJSON)
handlers = append(handlers, outputHandler)
JSON = cog.With(
handler.BuildPipe(handlers...),
)
}