...
1
2
3
4
5
6
7 package debug
8
9 import (
10 "os"
11 "strconv"
12 )
13
14
15 type Log interface {
16 Close() error
17 Info(eid uint32, msg string) error
18 Warning(eid uint32, msg string) error
19 Error(eid uint32, msg string) error
20 }
21
22
23 type ConsoleLog struct {
24 Name string
25 }
26
27
28 func New(source string) *ConsoleLog {
29 return &ConsoleLog{Name: source}
30 }
31
32
33 func (l *ConsoleLog) Close() error {
34 return nil
35 }
36
37 func (l *ConsoleLog) report(kind string, eid uint32, msg string) error {
38 s := l.Name + "." + kind + "(" + strconv.Itoa(int(eid)) + "): " + msg + "\n"
39 _, err := os.Stdout.Write([]byte(s))
40 return err
41 }
42
43
44 func (l *ConsoleLog) Info(eid uint32, msg string) error {
45 return l.report("info", eid, msg)
46 }
47
48
49 func (l *ConsoleLog) Warning(eid uint32, msg string) error {
50 return l.report("warn", eid, msg)
51 }
52
53
54 func (l *ConsoleLog) Error(eid uint32, msg string) error {
55 return l.report("error", eid, msg)
56 }
57
View as plain text