-
Notifications
You must be signed in to change notification settings - Fork 0
LogChannel
Maxime ROUFFET edited this page Apr 1, 2024
·
3 revisions
A LogChannel is a string composed of sub-channels with separators (./_-\|
).
When specifying a channel with the log macro, no "
are required.
Example:
SA_LOG("Hello", Normal, MyGlobalChannel.MySubChannel);
[19:2:10][0] {Normal - MyGlobalChannel/MySubChannel} main.cpp:53 - int main()
Msg: Hello
In order for a LogChannel to be enabled, all sub-channels parents must be enabled.
Example:
// Output only if "SA", "SA.Render", "SA.Render.Vulkan", and "SA.Render.Vulkan.Texture" are enabled.
SA_LOG("Texture Created.", Info, SA.Render.Vulkan.Texture);
// Disable all sub-channels children of "SA.Render".
SA::Debug::logger->DisableLogChannel(L"SA.Render");
The functions EnableLogChannel
and DisableLogChannel
are accessible from the Logger class to enable/disable a log channel in all registered streams.
Example:
// Disable 'MyAPI/MyChannel1' LogChannel for all streams.
SA::Debug::logger->DisableLogChannel(L"MyAPI/MyChannel1");
// Enable 'MyAPI/MyChannel2' LogChannel for all streams.
SA::Debug::logger->EnableLogChannel(L"MyAPI/MyChannel1");
A channelFilter
is accessible in each LogStream
to control whether or not a log with this channel should be output.
Example:
// Create and register LogStream.
SA::ConsoleLogStream& cslStream = SA::Debug::logger->CreateLogStream<SA::ConsoleLogStream>();
// Disable 'MyAPI/MyChannel1' LogChannel for this stream.
cslStream.channelFiler.SetChannelEnabled(L"MyAPI/MyChannel1", false);
// Enable 'MyAPI/MyChannel2' LogChannel for this stream.
cslStream.channelFiler.SetChannelEnabled(L"MyAPI/MyChannel2", true);