secureworks/logger
is a unified interface that wraps popular logging
libraries such as Logrus and Zerolog: 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.mod
s?- We have broken the packages up in order to keep dependencies in line with the log implementations. If you want
zerolog
you 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
safe
or!unsafe
build tag. This may be useful if you are building for an environment that does not allow unsafe (less type-safe) code. - For
zerolog
andlogrus
the unsafe code is used for a big performance boost. - For
zerolog
it also addresses a small behavior change in thezerolog.Hook
interface. 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/secureworks/errors |
Extracts error stack traces. | BSD 2-Clause |
github.com/rs/zerolog |
Logger. | MIT |
github.com/sirupsen/logrus |
Logger. | MIT |
As well as any transitive dependencies of the above.