Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/etw/sample: remove dependency on github.com/sirupsen/logrus #267

Merged
merged 1 commit into from
Feb 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions pkg/etw/sample/main_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ package main
import (
"bufio"
"fmt"
"log"
"os"
"runtime"

"github.com/Microsoft/go-winio/pkg/etw"
"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) {
Expand All @@ -24,31 +24,28 @@ func main() {

group, err := guid.FromString("12341234-abcd-abcd-abcd-123412341234")
if err != nil {
logrus.Error(err)
return
log.Fatal(err)
}

provider, err := etw.NewProvider("TestProvider", callback)

if err != nil {
logrus.Error(err)
return
log.Fatal(err)
}
defer func() {
if err := provider.Close(); err != nil {
logrus.Error(err)
log.Fatal(err)
}
}()

providerWithGroup, err := etw.NewProviderWithOptions("TestProviderWithGroup", etw.WithGroup(group), etw.WithCallback(callback))

if err != nil {
logrus.Error(err)
return
log.Fatal(err)
}
defer func() {
if err := providerWithGroup.Close(); err != nil {
logrus.Error(err)
log.Fatal(err)
}
}()

Expand Down Expand Up @@ -80,8 +77,7 @@ func main() {
"Item5",
})),
); err != nil {
logrus.Error(err)
return
log.Fatal(err)
}

if err := providerWithGroup.WriteEvent(
Expand All @@ -104,7 +100,6 @@ func main() {
"Item5",
})),
); err != nil {
logrus.Error(err)
return
log.Fatal(err)
}
}