secureworks/logger is a unified interface that wraps popular logging libraries such as Logrus and
Zerolog, and can instrument automatic reporting to services such as Sentry... And that is just
the beginning!
This is the logging library used in SecureWorks Taegis™ XDR (Extended Detection and Response) Cloud Platform, and is suggested for use with the Taegis Golang SDK.
This library is broken into submodules that are linked together. You may download them separately, but the easiest
thing to do is import whichever driver you want to use (logrus, zerolog, or testlogger), and these will
include the dependencies you need:
$ go get -u github.com/secureworks/logger/logrus
If you want the middleware you would also need:
$ go get -u github.com/secureworks/logger/middleware
Alternatively, if your project is using Go modules then, reference the driver package(s) in a file's import:
import (
// ...
"github.com/secureworks/logger/middleware"
_ "github.com/secureworks/logger/zerolog"
)You may run any Go command and the toolchain will resolve and fetch the required modules automatically.
Documentation is available on pkg.go.dev. You may also look at the examples in the logger package.
- Why are there so many submodules / why do all the packages have
go.mods?- We have broken the packages up in order to keep dependencies in line with the log implementations. If you want
zerologyou shouldn't also needlogrus; if you want to write code that consumes the shared interface you shouldn't need to depend on either implementation.
- We have broken the packages up in order to keep dependencies in line with the log implementations. If you want
- There are some packages with "safe" and "unsafe" versions of code. Why is this?
- unsafe refers to using the Go standard library
unsafe, which allows us to step outside of Go's type-safety rules. This code is no more "not safe" than a typical C program. - While we use the unsafe code (less type-safe) by default, this can be disabled by adding a
safeor!unsafebuild tag. This may be useful if you are building for an environment that does not allow unsafe (less type-safe) code. - For
zerologandlogrusthe unsafe code is used for a big performance boost. - For
zerologit also addresses a small behavior change in thezerolog.Hookinterface. See this issue for more.
- unsafe refers to using the Go standard library
This library is distributed under the Apache-2.0 license found in the LICENSE file.
| Library | Purpose | License |
|---|---|---|
github.com/pkg/errors |
Extracts error stack traces. | BSD 2-Clause |
github.com/rs/zerolog |
Logger. | MIT |
github.com/sirupsen/logrus |
Logger. | MIT |
github.com/getsentry/sentry-go |
Sentry SDK for error reporting. | BSD 2-Clause |
github.com/makasim/sentryhook |
Sentry hook for Logrus. | MIT |
Note: these are different based on what you import. Given which submodule(s) you use, the dependencies are included as follows:
github.com/secureworks/logger/log:
- No external dependencies.
github.com/secureworks/logger/testlogger:
- No external dependencies.
github.com/secureworks/logger/middleware:github.com/secureworks/logger/logrus:github.com/secureworks/logger/zerolog:
| Library | Purpose | License |
|---|---|---|
github.com/pkg/errors |
Extracts error stack traces. | BSD 2-Clause |
github.com/VerticalOps/fakesentry |
Run a fake Sentry server. | MIT |
github.com/getsentry/sentry-go |
Sentry SDK for error reporting. | BSD 2-Clause |