Skip to content

Commit

Permalink
Windows event log plugin (#2180)
Browse files Browse the repository at this point in the history
* add rmq message properties

* eventlog start

* start eventlog

* windows event logger

* readme

* readme

Co-authored-by: dtitov <[email protected]>
  • Loading branch information
korableg and dtitov authored Jun 20, 2021
1 parent 4daa499 commit 8dc9bf4
Show file tree
Hide file tree
Showing 6 changed files with 678 additions and 0 deletions.
28 changes: 28 additions & 0 deletions plugins/logger/windowseventlog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# WindowsEventLog

[windows event log](https://pkg.go.dev/golang.org/x/sys/windows/svc/eventlog) implementation for __go-micro__ [meta logger](https://github.com/micro/go-micro/tree/master/logger).

## Usage

Before the first use, it is necessary to initialize the registrar with administrator rights.

The __NewLogger__ function tries to create an event source named __src in the options__ (or by default), but this may not happen, so for proper initialization it is recommended to use the __Init__ function, which returns an error.
```go
func Init() {
l := windowseventlog.NewLogger(windowseventlog.WithSrc("test src"), logger.WithEid(1000))
err := l.Init()
if err != nil {
//smt
}
}
```


```go
func Example() {
logger.DefaultLogger = windowseventlog.NewLogger(windowseventlog.WithSrc("test src"), logger.WithEid(1000))

logger.Infof(logger.InfoLevel, "testing: %s", "Infof")

}
```
9 changes: 9 additions & 0 deletions plugins/logger/windowseventlog/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/korableg/go-micro/plugins/logger/windowseventlog

go 1.16

require (
github.com/asim/go-micro/v3 v3.5.1
github.com/stretchr/testify v1.7.0
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22
)
Loading

0 comments on commit 8dc9bf4

Please sign in to comment.