mirror of
https://github.com/rwinkhart/go-winio.git
synced 2026-09-06 09:07:18 -04:00
pkg/etw/sample: remove dependency on github.com/sirupsen/logrus (#267)
It looks like for the purpose of the example "a" logger was needed, so not strictly logrus (probably `fmt.Println()` would've worked even). This patch removes logrus as dependency for the example. The only remaining use of logrus in this repository is now in the pkg/etc/etwlogrus package, which _does_ need logrus, but (possibly) could become its own module if we want to remove logrus as dependency of go-winio itself. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -7,12 +7,12 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/Microsoft/go-winio/pkg/etw"
|
"github.com/Microsoft/go-winio/pkg/etw"
|
||||||
"github.com/Microsoft/go-winio/pkg/guid"
|
"github.com/Microsoft/go-winio/pkg/guid"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func callback(sourceID guid.GUID, state etw.ProviderState, level etw.Level, matchAnyKeyword uint64, matchAllKeyword uint64, filterData uintptr) {
|
func callback(sourceID guid.GUID, state etw.ProviderState, level etw.Level, matchAnyKeyword uint64, matchAllKeyword uint64, filterData uintptr) {
|
||||||
@@ -24,31 +24,28 @@ func main() {
|
|||||||
|
|
||||||
group, err := guid.FromString("12341234-abcd-abcd-abcd-123412341234")
|
group, err := guid.FromString("12341234-abcd-abcd-abcd-123412341234")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error(err)
|
log.Fatal(err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
provider, err := etw.NewProvider("TestProvider", callback)
|
provider, err := etw.NewProvider("TestProvider", callback)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error(err)
|
log.Fatal(err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := provider.Close(); err != nil {
|
if err := provider.Close(); err != nil {
|
||||||
logrus.Error(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
providerWithGroup, err := etw.NewProviderWithOptions("TestProviderWithGroup", etw.WithGroup(group), etw.WithCallback(callback))
|
providerWithGroup, err := etw.NewProviderWithOptions("TestProviderWithGroup", etw.WithGroup(group), etw.WithCallback(callback))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error(err)
|
log.Fatal(err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := providerWithGroup.Close(); err != nil {
|
if err := providerWithGroup.Close(); err != nil {
|
||||||
logrus.Error(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@@ -80,8 +77,7 @@ func main() {
|
|||||||
"Item5",
|
"Item5",
|
||||||
})),
|
})),
|
||||||
); err != nil {
|
); err != nil {
|
||||||
logrus.Error(err)
|
log.Fatal(err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := providerWithGroup.WriteEvent(
|
if err := providerWithGroup.WriteEvent(
|
||||||
@@ -104,7 +100,6 @@ func main() {
|
|||||||
"Item5",
|
"Item5",
|
||||||
})),
|
})),
|
||||||
); err != nil {
|
); err != nil {
|
||||||
logrus.Error(err)
|
log.Fatal(err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user