mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-04-06 22:57:37 +03:00
30 lines
828 B
Go
30 lines
828 B
Go
package dlog
|
|
|
|
import "golang.org/x/sys/windows/svc/eventlog"
|
|
|
|
type systemLogger struct {
|
|
inner *eventlog.Log
|
|
}
|
|
|
|
func newSystemLogger(appName string, facility string) (*systemLogger, error) {
|
|
eventlog.InstallAsEventCreate(appName, eventlog.Error|eventlog.Warning|eventlog.Info)
|
|
var eventLogger *eventlog.Log
|
|
var err error
|
|
if eventLogger, err = eventlog.Open(appName); err != nil {
|
|
return nil, err
|
|
}
|
|
return &systemLogger{inner: eventLogger}, nil
|
|
}
|
|
|
|
func (systemLogger *systemLogger) writeString(severity Severity, message string) {
|
|
switch severity {
|
|
case SeverityError:
|
|
case SeverityCritical:
|
|
case SeverityFatal:
|
|
systemLogger.inner.Error(uint32(severity), message)
|
|
case SeverityWarning:
|
|
systemLogger.inner.Warning(uint32(severity), message)
|
|
default:
|
|
systemLogger.inner.Info(uint32(severity), message)
|
|
}
|
|
}
|