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)...),
132#if LOCALZONE_IS_TIMEZONE
138 std::ostream *
lockLog()
override;
145 std::recursive_mutex m_lock;
161template<std::derived_from<std::ostream> T_Sink>
184 m_saved = m_snap.snap();
194 std::ostream *m_saved{};
198template<std::derived_from<I_SnapT<std::ostream*>> T_Sink>
218 operator bool()
const {
return m_locked !=
nullptr; }
227 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, bool use_local_time)
C_SyncLogger(I_ReenterableLog &impl, T_LocalZone tz_=T_LocalZone())
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()=default
Pointer deletion is not expected.
I_SyncLog(T_LocalZone tz_)
virtual std::ostream * lockLog()=0
Return non-null pointer if possible.
THE common namespace of bux library.
C_ReenterableLogger< C_PersistedSnapHolder > C_ReenterableOstreamSnap
@ LL_VERBOSE
More detailed or advanced information probably considered too much by some.
const std::chrono::time_zone * T_LocalZone
C_ReenterableLogger< C_OstreamHolder > C_ReenterableOstream
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.