The current logtest.Recorder implementation is wrong. We have a single
`Recorder`, which acts as both a `LoggerProvider`, and a `Logger`,
making it possible to emit a log entry with the root recorder, which
shouldn't be possible with the API.
This change introduces a new private struct, `logger` that acts as the
recording logger, while `Recorder` becomes only a LoggerProvider and not
a Logger anymore.
Closes#5357.
---------
Co-authored-by: Robert Pająk <pellared@hotmail.com>
* introduce in-memory log exporter
* add changelog entry
* move logtest into a recorder within the api
* rename GetRecords to Result
* rename InMemoryRecorder to Recorder
* name the struct r
* ensure Logger creates a struct copy
* replace severity with enabledFn
* Update CHANGELOG.md
Co-authored-by: Robert Pająk <pellared@hotmail.com>
* kUpdate log/logtest/config.go
Co-authored-by: Robert Pająk <pellared@hotmail.com>
* store all scope records, so we can retrieve everything with `Result()`
* store child loggers instead of all scope records
* no need to explicitly create a new slice
* add concurrent safe test
* handle default enabled function if the struct was manually created
* rename WithEnabledFn to WithEnabledFunc
* test result/reset with child loggers
* add enabled to concurrent safe
* fix lint missing period
* rename defaultEnabledFn to defaultEnabledFunc
* merge recorder.go and config.go
* Update log/logtest/recorder_test.go
Co-authored-by: Robert Pająk <pellared@hotmail.com>
* create empty recorder in concurrent safe test
* Update log/logtest/recorder_test.go
Co-authored-by: Robert Pająk <pellared@hotmail.com>
* fix lint
* Update log/logtest/recorder.go
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Update log/logtest/recorder.go
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Update log/logtest/recorder.go
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Update log/logtest/recorder.go
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Update log/logtest/recorder.go
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Update log/logtest/recorder.go
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Update log/logtest/recorder.go
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* Update log/logtest/recorder.go
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
* make enabledFunc callable from outside the package
* replace expected with want
---------
Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Sam Xie <sam@samxie.me>