mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
Defines a `winsvc.Event` type which can be sent using the `winsvc.SendEvent` function. If nomad is running on Windows and can send to the Windows Eventlog the event will be sent. Initial event types are defined for starting, ready, stopped, and log message. The `winsvc.EventLogger` provides an `io.WriteCloser` that can be included in the logger's writers collection. It will extract the log level from log lines and write them appropriately to the eventlog. The eventlog only supports error, warning, and info levels so messages with other levels will be ignored. A new configuration block is included for enabling logging to the eventlog. Logging must be enabled with the `log_level` option and the `eventlog.level` value can then be of the same or higher severity.
27 lines
834 B
Go
27 lines
834 B
Go
// Code generated by "stringer -trimprefix=EVENTLOG_LEVEL_ -output strings_event_logger.go -linecomment -type=EventlogLevel"; DO NOT EDIT.
|
|
|
|
package winsvc
|
|
|
|
import "strconv"
|
|
|
|
func _() {
|
|
// An "invalid array index" compiler error signifies that the constant values have changed.
|
|
// Re-run the stringer command to generate them again.
|
|
var x [1]struct{}
|
|
_ = x[EVENTLOG_LEVEL_UNKNOWN-0]
|
|
_ = x[EVENTLOG_LEVEL_INFO-1]
|
|
_ = x[EVENTLOG_LEVEL_WARN-2]
|
|
_ = x[EVENTLOG_LEVEL_ERROR-3]
|
|
}
|
|
|
|
const _EventlogLevel_name = "UNKNOWNINFOWARNERROR"
|
|
|
|
var _EventlogLevel_index = [...]uint8{0, 7, 11, 15, 20}
|
|
|
|
func (i EventlogLevel) String() string {
|
|
if i >= EventlogLevel(len(_EventlogLevel_index)-1) {
|
|
return "EventlogLevel(" + strconv.FormatInt(int64(i), 10) + ")"
|
|
}
|
|
return _EventlogLevel_name[_EventlogLevel_index[i]:_EventlogLevel_index[i+1]]
|
|
}
|