Skip to content

Commit

Permalink
chore: document that NullLogger is the default (#189)
Browse files Browse the repository at this point in the history
* chore: document that `NullLogger` is the default

Commit [9f7d0aa][1] introduced
`NullLogger` as the default logger, replacing `CerrLogger`.

This revision updates some relevant documentation.

I used `git grep CerrLogger` and [check-markdown-links][2] to find the
mismatches.

[1]: 9f7d0aa
[2]: https://github.com/dgoffredo/check-markdown-links
  • Loading branch information
dgoffredo authored Feb 26, 2025
1 parent 7fb5e59 commit c359348
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
10 changes: 7 additions & 3 deletions doc/maintainers.md
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,11 @@ be to have versions of the `Error`-returning operations that instead accept a
the present state of things is acceptable and that such a change is not
warranted.

The default implementation of `Logger` is `CerrLogger`, defined in
[cerr_logger.h][42]. `CerrLogger` logs to [std::cerr][43] in both `log_error`
The default implementation of `Logger` is `NullLogger`, defined in
[null_logger.h][47]. `NullLogger` doesn't log anything.

A client library might wish to install `CerrLogger` instead. `CerrLogger` is
defined in [cerr_logger.h][42] and logs to [std::cerr][43] in both `log_error`
and `log_startup`.

The `Logger` used by a `Tracer` is configured via `std::shared_ptr<Logger>
Expand Down Expand Up @@ -690,8 +693,9 @@ TODO
[39]: https://en.cppreference.com/w/cpp/utility/variant/get_if
[40]: https://en.cppreference.com/w/cpp/language/value_category
[41]: ../include/datadog/logger.h
[42]: ../src/datadog/cerr_logger.h
[42]: ../include/datadog/cerr_logger.h
[43]: https://en.cppreference.com/w/cpp/io/cerr
[44]: https://en.cppreference.com/w/cpp/utility/functional/function
[45]: https://github.com/DataDog/datadog-agent/blob/796ccb9e92326c85b51f519291e86eb5bc950180/pkg/trace/api/endpoints.go#L97
[46]: https://github.com/DataDog/dd-trace-cpp/tree/david.goffredo/traception
[47]: ../src/datadog/null_logger.h
3 changes: 0 additions & 3 deletions include/datadog/cerr_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
// This component provides a class, `CerrLogger`, that implements the `Logger`
// interface from `logger.h`. `CerrLogger` prints to `std::cerr`, which is
// typically an unbuffered stream to the standard error file.
//
// `CerrLogger` is the default logger used by `Tracer` unless otherwise
// configured in `TracerConfig`.

#include <datadog/logger.h>

Expand Down
4 changes: 2 additions & 2 deletions include/datadog/tracer_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ struct TracerConfig {
Optional<std::size_t> max_tags_header_size;

// `logger` specifies how the tracer will issue diagnostic messages. If
// `logger` is null, then it defaults to a logger that inserts into
// `std::cerr`.
// `logger` is null, then it defaults to no logging (`NullLogger`). See
// `CerrLogger` for an alternative.
std::shared_ptr<Logger> logger;

// `log_on_startup` indicates whether the tracer will log a banner of
Expand Down
2 changes: 0 additions & 2 deletions test/test_cerr_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class StreambufGuard {

} // namespace

// `CerrLogger` is the default logger.
// These test exist just to cover all of its methods.
TEST_CASE("CerrLogger") {
std::ostringstream stream;
const StreambufGuard guard{std::cerr, stream.rdbuf()};
Expand Down

0 comments on commit c359348

Please sign in to comment.