@@ -47,8 +47,8 @@ struct Sink : Filter {
4747 }
4848};
4949
50- struct LoggerBase {
51- virtual ~LoggerBase () = default ;
50+ struct OutputBase {
51+ virtual ~OutputBase () = default ;
5252 virtual void context (Metadata const & meta, bool entered, bool async_handover) = 0;
5353 virtual void emit (Event const & ev) = 0;
5454};
@@ -61,7 +61,7 @@ void set_output(Output<Sinks...>& sinks);
6161
6262template <typename ... Ts>
6363struct Output final
64- : LoggerBase
64+ : OutputBase
6565 , Any<Ts...> {
6666 template <typename ... Us>
6767 requires ((std::same_as<std::remove_cvref_t <Us>, std::remove_cvref_t <Ts>> && ...))
@@ -88,25 +88,26 @@ struct NullLogger {
8888
8989struct DefaultLogger {
9090 static void context (Metadata const & meta, bool entered, bool async_handover) {
91- if (auto * logger = output ()) {
92- logger ->context (meta, entered, async_handover);
91+ if (auto * output = current_output ()) {
92+ output ->context (meta, entered, async_handover);
9393 }
9494 }
9595
9696 template <LogLevel Severity, typename ... Args>
9797 static void emit (Metadata& meta, _impl::FormatString<Severity, Args...> fmt, Args&&... args) {
9898 auto message = fmt.make_message (std::forward<Args>(args)...);
9999 auto event = Event{.meta = meta, .text = message};
100- if (auto * logger = output ()) {
101- logger ->emit (event);
100+ if (auto * output = current_output ()) {
101+ output ->emit (event);
102102 }
103103 }
104104
105- static LoggerBase*& output ();
106- template <typename ... Sinks>
107- static void set_output (Output<Sinks...>& logger) {
108- output () = &logger;
105+ static void set_output (OutputBase& output) {
106+ current_output () = &output;
109107 }
108+
109+ private:
110+ static OutputBase*& current_output ();
110111};
111112
112113} // namespace rsl::logging
0 commit comments