4#ifndef _Stroika_Foundation_Execution_Logger_h_
5#define _Stroika_Foundation_Execution_Logger_h_ 1
7#include "Stroika/Foundation/StroikaPreComp.h"
14#include "Stroika/Foundation/Common/Common.h"
17#include "Stroika/Foundation/Execution/Signals.h"
35 using namespace Common;
37 using Characters::String;
102 using IAppenderRepPtr [[deprecated (
"Since Stroika v3.0d6 - just use shared_ptr<IAppenderRep>")]] = shared_ptr<IAppenderRep>;
105#if qStroika_HasComponent_syslog
106 class SysLogAppender;
109 class StreamAppender;
110#if qStroika_Foundation_Common_Platform_Windows
111 class WindowsEventLogAppender;
138#if qStroika_Foundation_Debug_AssertionsChecked
144 [[deprecated (
"Since Stroika v3.0d6 use GetAppenders - plural")]] nonvirtual shared_ptr<IAppenderRep> GetAppender ()
const
150 [[deprecated (
"Since Stroika v3.0d6 use SetAppenders - plural")]] nonvirtual
void SetAppender (
const shared_ptr<IAppenderRep>& rep)
169 nonvirtual
void SetAppenders (
const shared_ptr<IAppenderRep>& rep);
176 nonvirtual
void AddAppender (
const shared_ptr<IAppenderRep>& rep);
202 static constexpr Priority eDebug = Priority::eDebug;
203 static constexpr Priority eInfo = Priority::eInfo;
204 static constexpr Priority eNotice = Priority::eNotice;
205 static constexpr Priority eWarning = Priority::eWarning;
206 static constexpr Priority eCriticalError = Priority::eCriticalError;
207 static constexpr Priority eError = Priority::eError;
208 static constexpr Priority eAlertError = Priority::eAlertError;
209 static constexpr Priority eEmergency = Priority::eEmergency;
212 nonvirtual
void Shutdown_ ();
273 nonvirtual
void Flush ();
322 [[deprecated (
"Since Stroika v3.0d6 - use _f strings for Logging")]]
void Log (
Priority logLevel,
const wchar_t* format, ...);
323 template <
typename CHAR_T,
typename... ARGS>
333 shared_ptr<Rep_> fRep_{
nullptr};
334 Priority fMinLogLevel_{Priority::eInfo};
339 struct Logger::Options {
340 optional<bool> fLogBufferingEnabled;
341 optional<Time::Duration> fSuppressDuplicatesThreshold;
342 optional<Priority> fMinLogLevel;
365 class Logger::IAppenderRep {
367 virtual ~IAppenderRep () =
default;
373#if qStroika_HasComponent_syslog
376 class Logger::SysLogAppender :
public Logger::IAppenderRep {
378 SysLogAppender (
const String& applicationName);
379 SysLogAppender (
const String& applicationName,
int facility);
383 virtual void Log (Priority logLevel,
const String& message)
override;
386 string fApplicationName_;
392 class Logger::StreamAppender :
public Logger::IAppenderRep {
398 virtual void Log (
Priority logLevel,
const String& message)
override;
402 shared_ptr<Rep_> fRep_;
407 class Logger::FileAppender :
public Logger::IAppenderRep {
409 FileAppender (
const filesystem::path& fileName,
bool truncateOnOpen =
true);
412 virtual void Log (
Priority logLevel,
const String& message)
override;
416 shared_ptr<Rep_> fRep_;
419#if qStroika_Foundation_Common_Platform_Windows
422 class Logger::WindowsEventLogAppender :
public Logger::IAppenderRep {
424 WindowsEventLogAppender (
const String& eventSourceName);
427 virtual void Log (Priority logLevel,
const String& message)
override;
430 String fEventSourceName_;
#define Stroika_Define_Enum_Bounds(FIRST_ITEM, LAST_ITEM)
String is like std::u32string, except it is much easier to use, often much more space efficient,...
A simple/portable wrapper on syslog/log4j/WindowsEventlog, with features like throttling,...
nonvirtual bool WouldLog(Priority logLevel) const
nonvirtual optional< Time::Duration > GetSuppressDuplicates() const
nonvirtual Priority GetMinLogLevel() const
nonvirtual void SetAppenders(const shared_ptr< IAppenderRep > &rep)
void Log(Priority logLevel, const wchar_t *format,...)
nonvirtual void SetMinLogLevel(Priority minLogLevel)
nonvirtual Traversal::Iterable< shared_ptr< IAppenderRep > > GetAppenders() const
nonvirtual void SetSuppressDuplicates(const optional< Time::Duration > &suppressDuplicatesThreshold)
nonvirtual bool GetBufferingEnabled() const
nonvirtual void AddAppender(const shared_ptr< IAppenderRep > &rep)
nonvirtual void SetBufferingEnabled(bool logBufferingEnabled)
OutputStream<>::Ptr is Smart pointer to a stream-based sink of data.
Iterable<T> is a base class for containers which easily produce an Iterator<T> to traverse them.
conditional_t< qTargetPlatformSDKUseswchar_t, wchar_t, char > SDKChar
void DefaultLoggingCrashSignalHandler(Execution::SignalID signal) noexcept
void DefaultLoggingFatalErrorHandler(const Characters::SDKChar *msg) noexcept