forked from nats-io/nats-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyslog_windows.go
52 lines (42 loc) · 1.07 KB
/
syslog_windows.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
// Copyright 2012-2014 Apcera Inc. All rights reserved.
package logger
import (
"fmt"
"log"
"os"
)
type SysLogger struct {
writer *log.Logger
debug bool
trace bool
}
func NewSysLogger(debug, trace bool) *SysLogger {
w := log.New(os.Stdout, "gnatsd", log.LstdFlags)
return &SysLogger{
writer: w,
debug: debug,
trace: trace,
}
}
func NewRemoteSysLogger(fqn string, debug, trace bool) *SysLogger {
return NewSysLogger(debug, trace)
}
func (l *SysLogger) Noticef(format string, v ...interface{}) {
l.writer.Println("NOTICE", fmt.Sprintf(format, v...))
}
func (l *SysLogger) Fatalf(format string, v ...interface{}) {
l.writer.Println("CRITICAL", fmt.Sprintf(format, v...))
}
func (l *SysLogger) Errorf(format string, v ...interface{}) {
l.writer.Println("ERROR", fmt.Sprintf(format, v...))
}
func (l *SysLogger) Debugf(format string, v ...interface{}) {
if l.debug {
l.writer.Println("DEBUG", fmt.Sprintf(format, v...))
}
}
func (l *SysLogger) Tracef(format string, v ...interface{}) {
if l.trace {
l.writer.Println("NOTICE", fmt.Sprintf(format, v...))
}
}