Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Logger.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
5
7
8 /*
9 ********************************************************************************
10 ********************************* Logger ***************************************
11 ********************************************************************************
12 */
13 inline Logger Logger::sThe;
15 {
16 return fMinLogLevel_;
17 }
18 inline void Logger::SetMinLogLevel (Priority minLogLevel)
19 {
20 fMinLogLevel_ = minLogLevel;
21 }
22 inline bool Logger::WouldLog (Priority logLevel) const
23 {
24 return logLevel >= fMinLogLevel_ and not GetAppenders ().empty ();
25 }
26#if !qStroika_Foundation_Debug_DefaultTracingOn
27 inline void Logger::Log (Priority logLevel, const wchar_t* format, ...)
28 {
29 if (WouldLog (logLevel)) {
30 va_list argsList;
31 va_start (argsList, format);
32 String msg = Characters::FormatV (format, argsList);
33 va_end (argsList);
34 Log_ (logLevel, msg);
35 }
36 }
37#endif
38 template <typename CHAR_T, typename... ARGS>
39 inline void Logger::Log (Priority logLevel, const Characters::FormatString<CHAR_T>& fmt, ARGS&&... args)
40 {
41 using namespace Characters::Literals;
42 if (WouldLog (logLevel)) {
43 String msg = fmt (args...);
44 DbgTrace ("Logger::Log ({}, \"{}\")"_f, logLevel, msg);
45 Log_ (logLevel, msg);
46 }
47 else {
48#if qStroika_Foundation_Debug_DefaultTracingOn
49 DbgTrace ("...suppressed by WouldLog: {}"_f, fmt (args...));
50#endif
51 }
52 }
53
54}
55
57 template <>
58 constexpr EnumNames<Execution::Logger::Priority> DefaultNames<Execution::Logger::Priority>::k{{{
59 {Execution::Logger::Priority::eDebug, L"Debug"},
60 {Execution::Logger::Priority::eInfo, L"Info"},
61 {Execution::Logger::Priority::eNotice, L"Notice"},
62 {Execution::Logger::Priority::eWarning, L"Warning"},
63 {Execution::Logger::Priority::eError, L"Error"},
64 {Execution::Logger::Priority::eCriticalError, L"CriticalError"},
65 {Execution::Logger::Priority::eAlertError, L"AlertError"},
66 {Execution::Logger::Priority::eEmergency, L"Emergency"},
67 }}};
68}
#define DbgTrace
Definition Trace.h:309
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
nonvirtual bool WouldLog(Priority logLevel) const
Definition Logger.inl:22
nonvirtual Priority GetMinLogLevel() const
Definition Logger.inl:14
void Log(Priority logLevel, const wchar_t *format,...)
Definition Logger.inl:27
nonvirtual void SetMinLogLevel(Priority minLogLevel)
Definition Logger.inl:18
nonvirtual Traversal::Iterable< shared_ptr< IAppenderRep > > GetAppenders() const
Definition Logger.cpp:233
Roughly equivalent to std::wformat_string, except that it can be constructed from 'char' string,...