github.com/zhongdalu/gf@v1.0.0/third/golang.org/x/sys/windows/svc/debug/log.go (about) 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. 4 5 // +build windows 6 7 package debug 8 9 import ( 10 "os" 11 "strconv" 12 ) 13 14 // Log interface allows different log implementations to be used. 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 // ConsoleLog provides access to the console. 23 type ConsoleLog struct { 24 Name string 25 } 26 27 // New creates new ConsoleLog. 28 func New(source string) *ConsoleLog { 29 return &ConsoleLog{Name: source} 30 } 31 32 // Close closes console log l. 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 // 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) 46 } 47 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) 51 } 52 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) 56 }