Update Logger functions to use Sprintf.

This commit is contained in:
Daniel Theophanes
2012-03-09 23:35:27 -08:00
parent b790f755c5
commit e5ca8cfda8
2 changed files with 10 additions and 9 deletions
+3 -3
View File
@@ -22,7 +22,7 @@ type Service interface {
Run(onStart, onStop func() error) error Run(onStart, onStop func() error) error
// Basic log functions in the context of the service. // Basic log functions in the context of the service.
LogError(text string) error LogError(format string, a ...interface{}) error
LogWarning(text string) error LogWarning(format string, a ...interface{}) error
LogInfo(text string) error LogInfo(format string, a ...interface{}) error
} }
+7 -6
View File
@@ -3,6 +3,7 @@ package service
import ( import (
"syscall" "syscall"
"unicode/utf16" "unicode/utf16"
"fmt"
"unsafe" "unsafe"
) )
@@ -93,14 +94,14 @@ func (ws *windowsService) Run(onStart, onStop func() error) error {
return runService(ws.name, onStart, onStop) return runService(ws.name, onStart, onStop)
} }
func (ws *windowsService) LogError(text string) error { func (ws *windowsService) LogError(format string, a ...interface{}) error {
return writeToEventLog(ws.name, text, levelError) return writeToEventLog(ws.name, fmt.Sprintf(format, a ...), levelError)
} }
func (ws *windowsService) LogWarning(text string) error { func (ws *windowsService) LogWarning(format string, a ...interface{}) error {
return writeToEventLog(ws.name, text, levelWarning) return writeToEventLog(ws.name, fmt.Sprintf(format, a ...), levelWarning)
} }
func (ws *windowsService) LogInfo(text string) error { func (ws *windowsService) LogInfo(format string, a ...interface{}) error {
return writeToEventLog(ws.name, text, levelInfo) return writeToEventLog(ws.name, fmt.Sprintf(format, a ...), levelInfo)
} }
var ( var (