Skip to content

freman/eventloghook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Windows EventLog hooks for Logrus :walrus:

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))
}

About

Windows EventLog hooks for Logrus

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages