25 const std::chrono::time_zone *
const tz;
46template<
class C_SinkRefHolder>
requires requires (C_SinkRefHolder holder)
48 { holder.stream() }-> std::convertible_to<std::ostream*>;
65 auto ret = m_maxLevel;
74 if (
const auto ret = m_refHolder.stream()) [[likely]]
83 return ll <= m_maxLevel?
useLog():
nullptr;
88 m_refHolder.stream()->flush();
90 if (!--m_lockCount) [[likely]]
97 C_SinkRefHolder m_refHolder;
99 E_LogLevel m_maxLevel;
102template<
class C_LogImpl>
108template<class C_LogImpl, class C_SinkRefHolder = typename C_AutoSinkHolderT<C_LogImpl>::type>
114 template<
class...T_Args>
116 C_LogImpl(std::forward<T_Args>(args)...),
133 C_SyncLogger(impl, use_local_time? std::chrono::get_tzdb().current_zone(): nullptr) {}
136 std::ostream *
lockLog()
override;
143 std::recursive_mutex m_lock;
159template<std::derived_from<std::ostream> T_Sink>
182 m_saved = m_snap.
snap();
192 std::ostream *m_saved{};
196template<std::derived_from<I_SnapT<std::ostream*>> T_Sink>
216 operator bool()
const {
return m_locked !=
nullptr; }
225 std::ostream *
const m_locked;
C_PersistedSnapHolder(I_SnapT< std::ostream * > &snap)
C_ReenterableLoggerInside(E_LogLevel ll, T_Args &&...args)
std::ostream * useLog() override
Return non-null pointer if possible.
auto setLogLevel(E_LogLevel level)
C_ReenterableLogger(T &ref, E_LogLevel max_ll=LL_VERBOSE)
std::ostream * useLog(E_LogLevel ll) override
Return non-null pointer if logging is permitted to log level ll.
void unuseLog(bool flush) override
If the previous call to lockLog() returned null, the behavior is undefined.
std::ostream * lockLog() override
void unlockLog(bool flush) override
C_SyncLogger(I_ReenterableLog &impl, const std::chrono::time_zone *tz_=nullptr)
C_SyncLogger(I_ReenterableLog &impl, bool use_local_time)
C_UseLog(I_SyncLog &obj, E_LogLevel level)
</// Thread safety is expected
virtual std::ostream * lockLog(E_LogLevel ll)=0
Return non-null pointer if logging is permitted for the given log level ll.
virtual void unlockLog(bool flush=true)=0
If the previous call to lockLog() returned null, the behavior is undefined.
I_SyncLog(const std::chrono::time_zone *tz_)
const std::chrono::time_zone *const tz
~I_SyncLog()=default
Pointer deletion is not expected.
virtual std::ostream * lockLog()=0
Return non-null pointer if possible.
THE common namespace of bux library.
C_OstreamHolder(std::ostream &out)
std::ostream * stream() const
Thread-unsafe implementation is preferred for performance.
virtual std::ostream * useLog(E_LogLevel ll)=0
Return non-null pointer if logging is permitted to log level ll.
virtual ~I_ReenterableLog()=default
Pointer deletion is hereby granted.
virtual void unuseLog(bool flush)=0
If the previous call to lockLog() returned null, the behavior is undefined.
virtual std::ostream * useLog()=0
Return non-null pointer if possible.
virtual T snap()=0
Snap the current T value.
virtual ~I_SnapT()=default
Pointer deletion is hereby granted.