Update Logger functions to use Sprintf.
This commit is contained in:
+3
-3
@@ -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
@@ -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 (
|
||||||
|
|||||||
Reference in New Issue
Block a user