eventloghook

package module
v0.0.0-...-ac7a0ab Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2025 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Windows EventLog hooks for Logrus

Usage

import (
  "log/syslog"
  "github.com/sirupsen/logrus"
  "github.com/Freman/eventloghook"
  "golang.org/x/sys/windows/svc/eventlog"
)

func main() {
  log       := logrus.New()
  elog, err = eventlog.Open("Service Name")
  if err != nil {
    panic(err)
  }
  defer elog.Close()
  log.Hooks.Add(eventloghook.NewHook(elog))
}

If you want to output to the windows console/terminal - tho why you'd want to do that vs use logrus built in method I have no idea :D

import (
  "log/syslog"
  "github.com/Sirupsen/logrus"
  "github.com/Freman/eventloghook"
  "golang.org/x/sys/windows/svc/debug"
)

func main() {
  log       := logrus.New()
  elog = debug.New("Service Name")
  defer elog.Close()
  log.Hooks.Add(eventloghook.NewHook(elog))
}

Documentation

Rendered for windows/amd64

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventLogHook

type EventLogHook struct {
	// contains filtered or unexported fields
}

EventLogHook to send logs via windows log.

func NewHook

func NewHook(logger eventlog.Log) *EventLogHook

NewHook creates and returns a new EventLogHook wrapped around anything that implements the eventlog.Log interface

func (*EventLogHook) Fire

func (hook *EventLogHook) Fire(entry *logrus.Entry) error

func (*EventLogHook) Levels

func (hook *EventLogHook) Levels() []logrus.Level

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL