From 9a32b3c7ebc7cba4d827352ead22642b4e321c47 Mon Sep 17 00:00:00 2001 From: David Goffredo Date: Fri, 21 Feb 2025 18:03:41 -0500 Subject: [PATCH 1/2] chore: document that `NullLogger` is the default Commit [9f7d0aa0a82795f8a5a134b4b44332955360d43a][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]: https://github.com/DataDog/dd-trace-cpp/commit/9f7d0aa0a82795f8a5a134b4b44332955360d43a [2]: https://github.com/dgoffredo/check-markdown-links --- doc/maintainers.md | 10 +++++++--- include/datadog/cerr_logger.h | 3 --- test/test_cerr_logger.cpp | 2 -- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/doc/maintainers.md b/doc/maintainers.md index d36ee126..40273768 100644 --- a/doc/maintainers.md +++ b/doc/maintainers.md @@ -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 @@ -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 diff --git a/include/datadog/cerr_logger.h b/include/datadog/cerr_logger.h index 1b434681..63945ce0 100644 --- a/include/datadog/cerr_logger.h +++ b/include/datadog/cerr_logger.h @@ -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 diff --git a/test/test_cerr_logger.cpp b/test/test_cerr_logger.cpp index ce7d92c1..472ae60b 100644 --- a/test/test_cerr_logger.cpp +++ b/test/test_cerr_logger.cpp @@ -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()}; From 6c03b841ed480e7944c480a2317741c235db4372 Mon Sep 17 00:00:00 2001 From: David Goffredo Date: Fri, 21 Feb 2025 18:21:08 -0500 Subject: [PATCH 2/2] I missed a spot. --- include/datadog/tracer_config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/datadog/tracer_config.h b/include/datadog/tracer_config.h index 3752cb26..30f3324c 100644 --- a/include/datadog/tracer_config.h +++ b/include/datadog/tracer_config.h @@ -121,8 +121,8 @@ struct TracerConfig { Optional 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; // `log_on_startup` indicates whether the tracer will log a banner of