user1307957
user1307957

Reputation: 541

Pantheios set display level in C++

I'm using Pantheios library for logging. I have:

pantheios::log(pantheios::debug, "I'm debug");
pantheios::log(pantheios::informational, "Some info");

Which outputs:

[MyApplication, Jun 14 15:45:26.549; Debug] : I'm debug
[MyApplication.1, Jun 14 15:45:26.549; Informational] : Some info

But I want to choose between display info and debug:

 set_level(pantheios::informational) //what should this be ?
 pantheios::log(pantheios::debug, "I'm debug");
 pantheios::log(pantheios::informational, "Some info");

Which outputs:

[MyApplication.1, Jun 14 15:45:26.549; Informational] : Some info

Upvotes: 1

Views: 685

Answers (1)

Eitan T
Eitan T

Reputation: 32930

The "right" way to actually filter log levels is to customize the logger front-end and override pantheios::pantheios_fe_isSevereityLogged(), something along these lines:

namespace
{
    static int s_log_level = pantheios::debug;
}

PANTHEIOS_CALL(int) pantheios_fe_isSeverityLogged(void *token,
    int severity, int backEndId)
{
    return severity <= s_log_level;
}

You should refer to this and this example for more information.

Upvotes: 5

Related Questions