bosun.org@v0.0.0-20210513094433-e25bc3e69a1f/slog/slog_windows.go (about)

     1  package slog
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"golang.org/x/sys/windows/svc/debug"
     7  )
     8  
     9  type eventLog struct {
    10  	l  debug.Log
    11  	id uint32
    12  }
    13  
    14  // Sets the logger to a Windows Event Log. Designed for use with the
    15  // code.google.com/p/winsvc/eventlog and code.google.com/p/winsvc/debug
    16  // packages.
    17  func SetEventLog(l debug.Log, eid uint32) {
    18  	Set(&eventLog{l, eid})
    19  }
    20  
    21  func (e *eventLog) Fatal(v string) {
    22  	e.l.Error(e.id, fmt.Sprintf("fatal: %s", v))
    23  }
    24  
    25  func (e *eventLog) Info(v string) {
    26  	e.l.Info(e.id, fmt.Sprintf("info: %s", v))
    27  }
    28  
    29  func (e *eventLog) Warning(v string) {
    30  	e.l.Warning(e.id, fmt.Sprintf("warning: %s", v))
    31  }
    32  func (e *eventLog) Error(v string) {
    33  	e.l.Error(e.id, fmt.Sprintf("error: %s", v))
    34  }