3#include <Foundation/Communication/Event.h>
4#include <Foundation/Strings/FormatString.h>
5#include <Foundation/Strings/StringBuilder.h>
6#include <Foundation/Strings/StringUtils.h>
7#include <Foundation/Threading/AtomicInteger.h>
8#include <Foundation/Time/Time.h>
12#define PL_LOG_BLOCK plLogBlock PL_PP_CONCAT(_logblock_, PL_SOURCE_LINE)
15#define PL_LOG_BLOCK_MUTE() \
16 plMuteLog PL_PP_CONCAT(_logmuteblock_, PL_SOURCE_LINE); \
17 plLogSystemScope PL_PP_CONCAT(_logscope_, PL_SOURCE_LINE)(&PL_PP_CONCAT(_logmuteblock_, PL_SOURCE_LINE))
26 using StorageType = plInt8;
36 SeriousWarningMsg = 2,
55 plUInt8 m_uiIndentation = 0;
64#if PL_ENABLED(PL_COMPILE_FOR_DEVELOPMENT)
66 double m_fSeconds = 0;
94 plUInt32 m_uiLoggedMsgsSinceFlush = 0;
129 static void RemoveLogWriter(plEventSubscriptionID& ref_subscriptionID);
188 template <
typename... ARGS>
195 template <
typename... ARGS>
205 template <
typename... ARGS>
212 template <
typename... ARGS>
222 template <
typename... ARGS>
229 template <
typename... ARGS>
239 template <
typename... ARGS>
246 template <
typename... ARGS>
256 template <
typename... ARGS>
263 template <
typename... ARGS>
277 template <
typename... ARGS>
284 template <
typename... ARGS>
298 template <
typename... ARGS>
305 template <
typename... ARGS>
339 static void Print(
const char* szText);
344 static void Printf(
const char* szFormat, ...);
366 static void GenerateFormattedTimestamp(TimestampMode mode,
plStringBuilder& ref_sTimestampOut);
380 static PrintFunction s_CustomPrintFunction;
414 plUInt8 m_uiBlockDepth;
416#if PL_ENABLED(PL_COMPILE_FOR_DEVELOPMENT)
473#include <Foundation/Logging/Implementation/Log_inl.h>
plDelegate< void(const plLoggingEventData &)> Handler
Definition Event.h:45
This is the standard log system that plLog sends all messages to.
Definition Log.h:118
static plUInt32 GetMessageCount(plLogMsgType::Enum messageType)
Returns how many message of the given type occurred.
Definition Log.h:132
Instances of this class will group messages in a scoped block together.
Definition Log.h:386
Static class that allows to write out logging information.
Definition Log.h:167
static void Debug(plStringView sFormat, ARGS &&... args)
Status information during debugging. Very verbose. Usually only temporarily added to the code.
Definition Log.h:299
static void SeriousWarning(plLogInterface *pInterface, plStringView sFormat, ARGS &&... args)
Overload of SeriousWarning() to output messages to a specific log.
Definition Log.h:213
static void Debug(plLogInterface *pInterface, plStringView sFormat, ARGS &&... args)
Overload of Debug() to output messages to a specific log.
Definition Log.h:306
static void Info(plStringView sFormat, ARGS &&... args)
Status information that is important.
Definition Log.h:257
static void Dev(plLogInterface *pInterface, const plFormatString &string)
Status information that is nice to have during development.
void(*)(const char *szText) PrintFunction
Signature of the custom print function used by plLog::SetCustomPrintFunction.
Definition Log.h:347
static void Info(plLogInterface *pInterface, plStringView sFormat, ARGS &&... args)
Overload of Info() to output messages to a specific log.
Definition Log.h:264
TimestampMode
This enum is used in context of outputting timestamp information to indicate a formatting for said ti...
Definition Log.h:359
static void Error(plStringView sFormat, ARGS &&... args)
An error that needs to be fixed as soon as possible.
Definition Log.h:189
static void Warning(plLogInterface *pInterface, plStringView sFormat, ARGS &&... args)
Overload of Warning() to output messages to a specific log.
Definition Log.h:230
static void Dev(plStringView sFormat, ARGS &&... args)
Status information that is nice to have during development.
Definition Log.h:278
static void Debug(plLogInterface *pInterface, const plFormatString &string)
Status information during debugging. Very verbose. Usually only temporarily added to the code.
static void Error(plLogInterface *pInterface, plStringView sFormat, ARGS &&... args)
Overload of Error() to output messages to a specific log.
Definition Log.h:196
static void Dev(plLogInterface *pInterface, plStringView sFormat, ARGS &&... args)
Overload of Dev() to output messages to a specific log.
Definition Log.h:285
static void Success(plLogInterface *pInterface, plStringView sFormat, ARGS &&... args)
Overload of Success() to output messages to a specific log.
Definition Log.h:247
static void Warning(plStringView sFormat, ARGS &&... args)
A potential problem or a performance warning. Might be possible to ignore it.
Definition Log.h:223
static void SetThreadLocalLogSystem(plLogInterface *pInterface)
Allows to change which logging system is used by default on the current thread. If nothing is set,...
Definition Log.cpp:337
static void Success(plStringView sFormat, ARGS &&... args)
Status information that something was completed successfully.
Definition Log.h:240
static plLogInterface * GetThreadLocalLogSystem()
Returns the currently set default logging system, or a thread local instance of plGlobalLog,...
Definition Log.cpp:345
static void SeriousWarning(plStringView sFormat, ARGS &&... args)
Not an error, but definitely a big problem, that should be looked into very soon.
Definition Log.h:206
Base class for all logging classes.
Definition Log.h:77
PL_ALWAYS_INLINE plLogMsgType::Enum GetLogLevel()
Returns the currently set log level.
Definition Log.h:87
virtual void HandleLogMessage(const plLoggingEventData &le)=0
Override this function to handle logging events.
PL_ALWAYS_INLINE void SetLogLevel(plLogMsgType::Enum logLevel)
LogLevel is between plLogEventType::None and plLogEventType::All and defines which messages will be l...
Definition Log.h:84
A class that sets a custom plLogInterface as the thread local default log system, and resets the prev...
Definition Log.h:424
plLogSystemScope(plLogInterface *pInterface)
The given plLogInterface is passed to plLog::SetThreadLocalLogSystem().
Definition Log.h:427
~plLogSystemScope()
Resets the previous plLogInterface through plLog::SetThreadLocalLogSystem()
Definition Log.h:434
A simple log interface implementation that gathers all messages in a string buffer.
Definition Log.h:446
virtual void HandleLogMessage(const plLoggingEventData &le) override
Override this function to handle logging events.
Definition Log.h:448
Used to ignore all log messages.
Definition Log.h:102
virtual void HandleLogMessage(const plLoggingEventData &) override
Override this function to handle logging events.
Definition Log.h:109
plStringBuilder is a class that is meant for creating and modifying strings.
Definition StringBuilder.h:35
void Append(plUInt32 uiChar)
Appends a single Utf32 character.
Definition StringBuilder_inl.h:94
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
Describes the types of events that plLog sends.
Definition Log.h:25
@ SeriousWarningMsg
A serious warning message.
Definition Log.h:36
@ InfoMsg
An info message.
Definition Log.h:39
@ DebugMsg
A debug message.
Definition Log.h:41
@ None
Can be used to disable all log message types.
Definition Log.h:34
@ GlobalDefault
Takes the log level from the plLog default value. See plLog::SetDefaultLogLevel().
Definition Log.h:30
@ SuccessMsg
A success message.
Definition Log.h:38
@ ErrorMsg
An error message.
Definition Log.h:35
@ WarningMsg
A warning message.
Definition Log.h:37
@ DevMsg
A development message.
Definition Log.h:40
The data that is sent through plLogInterface.
Definition Log.h:50
plLogMsgType::Enum m_EventType
The type of information that is sent.
Definition Log.h:52
plStringView m_sText
The information text.
Definition Log.h:58
plStringView m_sTag
An optional tag extracted from the log-string (if it started with "[SomeTag]Logging String....
Definition Log.h:62
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12
PL_ALWAYS_INLINE static constexpr plTime MakeFromSeconds(double fSeconds)
Creates an instance of plTime that was initialized from seconds.
Definition Time.h:30