Skip to content

Commit e671535

Browse files
committed
fix logging: fix dynamic debug logs in templates
Previously, dynamic debug logs could not turn on or off log lines within template functions correctly. commit_hash:3ada07ac11569b97a38e79c53070692f6d6f4430
1 parent 5b5279e commit e671535

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

core/src/components/minimal_server_component_list_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ constexpr std::string_view kStaticConfig = R"(
5151
worker_threads: 4
5252
task-trace:
5353
every: 1
54-
max-context-switch-count: 50
54+
max-context-switch-count: 1000
5555
logger: tracer
5656
components:
5757
logging:

scripts/docs/en/userver/component_system.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ A userver-based service usually consists of components. A component is a basic
44
building block that encapsulates dependencies logic with configuration and
55
is able to interact with other components.
66

7+
Each component is a singleton within a service instance, so they should only encapsulate global state,
8+
not per-request state. (Although *factories* for per-request objects may be appropriate.)
9+
Any mutable state probably needs @ref scripts/docs/en/userver/synchronization.md "synchronization".
10+
Built-in userver components perform synchronization internally when needed and are fully thread-safe
11+
unless specified otherwise.
12+
713
\b Example:
814

915
* There is a `ClientB`, that requires initialization with some `SettingsB`

universal/src/logging/dynamic_debug.hpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ struct LogEntryContent {
3939
bool operator<(const LogEntryContent& x, const LogEntryContent& y) noexcept;
4040
bool operator==(const LogEntryContent& x, const LogEntryContent& y) noexcept;
4141

42-
using LogEntryContentSet = bi::set< //
43-
LogEntryContent, //
44-
bi::constant_time_size<false>, //
45-
bi::member_hook< //
46-
LogEntryContent, //
47-
LogEntryContentHook, //
48-
&LogEntryContent::hook //
49-
> //
42+
// multiset to allow multiple logs on the same line (happens with templates).
43+
using LogEntryContentSet = bi::multiset< //
44+
LogEntryContent, //
45+
bi::constant_time_size<false>, //
46+
bi::member_hook< //
47+
LogEntryContent, //
48+
LogEntryContentHook, //
49+
&LogEntryContent::hook //
50+
> //
5051
>;
5152

5253
void AddDynamicDebugLog(

0 commit comments

Comments
 (0)