Further improve logging system
Complain when too many channels
This commit is contained in:
parent
c2b100428d
commit
09bf4ba110
|
@ -11,6 +11,7 @@ namespace Feather::Logging
|
|||
Logger GlobalLogger;
|
||||
|
||||
ChannelID LOG_GENERAL = REGISTER_LOGGING_CHANNEL("General");
|
||||
ChannelID LOG_LOGGING = REGISTER_LOGGING_CHANNEL("Logging");
|
||||
|
||||
// Since min and max are inclusive we have to add 1 here
|
||||
// This assumes max > min (they better be)
|
||||
|
@ -84,10 +85,11 @@ namespace Feather::Logging
|
|||
|
||||
ChannelID Logger::RegisterChannel(const char* name)
|
||||
{
|
||||
Channel* channel = new Channel(name);
|
||||
if (m_channelCount >= MAX_LOGGING_CHANNEL_COUNT) {
|
||||
// complain
|
||||
Log_Msg( LOG_LOGGING, ERROR, "Cannot register new logging channel '%s' because the maximum of %d channels has been exceeded.", name, MAX_LOGGING_CHANNEL_COUNT );
|
||||
return LOG_GENERAL;
|
||||
}
|
||||
Channel *channel = new Channel(name);
|
||||
m_channels[m_channelCount] = channel;
|
||||
int id = m_channelCount++;
|
||||
return id;
|
||||
|
@ -118,6 +120,7 @@ static void InitPlatformConsole()
|
|||
DWORD mode = 0;
|
||||
if (GetConsoleMode(handle, &mode))
|
||||
{
|
||||
// To enable ANSI escape sequences on Windows 10 we need to set this flag
|
||||
mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
||||
SetConsoleMode(handle, mode);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue