Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a new `olog` package with the intent of replacing the existing `log` package. Based off of the Go Observability Tooling design document[^1]. For those without access to that document, the main goals are encapsulated below: - Uses `*slog.Logger` as the returned logging library ([Highly recommended read about the library](https://go.dev/blog/slog)) - Loggers must be instantiated with `New()` before a log line can be emitted, there is no singleton provided by the olog package. - Packages should create their own logger(s) as required, storing it as a package-level global singleton for ease of use (however, loggers can also be created on the fly). - Default global logging level of Info, which all `New()` loggers respect. Ability to change log level at a module and package level. Adjustable through configuration while the process is still running. - Creating wrapped loggers using a provided `*slog.Logger` (ideally from `New()`) to enable Outreach-specific functionality, like audit logs. - Pretty printing of logs by default when `os.Stderr` is a TTY (local development). - Automatically log otel-logging compliant TraceID and SpanID if a context with trace information is passed to the logger. - **This will require <Level>Context function calls to work.** Expected usage is calling `New` to create new logger _per package_. This should be done either as a global variable per-package, or once per-package and passed around. Provides a test helper (`NewTestCapturer`) that enables callers to capture all log output for the purpose of checking the output/result of certain operations via logs. This is primarily intended to be used only for the development of the logger, since logs are not a stable way to ensure an operation has occurred. [^1]: https://outreach-io.atlassian.net/wiki/spaces/DT/pages/2853765388/Go+Observability+Tooling+Design#Logging --------- Co-authored-by: Jared Allard <[email protected]> Co-authored-by: Professor X <[email protected]> Co-authored-by: Alex Hester <[email protected]> Co-authored-by: Mark Lee <[email protected]> Co-authored-by: Devbase CI <[email protected]>
- Loading branch information