1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
14 // Log interface allows different log implementations to be used.
17 Info(eid uint32, msg string) error
18 Warning(eid uint32, msg string) error
19 Error(eid uint32, msg string) error
22 // ConsoleLog provides access to the console.
23 type ConsoleLog struct {
27 // New creates new ConsoleLog.
28 func New(source string) *ConsoleLog {
29 return &ConsoleLog{Name: source}
32 // Close closes console log l.
33 func (l *ConsoleLog) Close() error {
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))
43 // Info writes an information event msg with event id eid to the console l.
44 func (l *ConsoleLog) Info(eid uint32, msg string) error {
45 return l.report("info", eid, msg)
48 // Warning writes an warning event msg with event id eid to the console l.
49 func (l *ConsoleLog) Warning(eid uint32, msg string) error {
50 return l.report("warn", eid, msg)
53 // Error writes an error event msg with event id eid to the console l.
54 func (l *ConsoleLog) Error(eid uint32, msg string) error {
55 return l.report("error", eid, msg)