1

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
1201ProgramAlarm
  • 32,384
  • 7
  • 42
  • 56
user1307957
  • 541
  • 3
  • 8
  • 19
  • http://dinhngocson.blogspot.com/2010/11/pantheios-logging-library-basic.html –  Jun 14 '12 at 13:35

1 Answers1

5

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.

Eitan T
  • 32,660
  • 14
  • 72
  • 109
  • Gave me multiple definition error with using of pantheios.1.fe.simple.gcc46 (also with pantheios.1.fe.all.gcc46) – user1307957 Jun 15 '12 at 15:13
  • My code was meant only to give the general idea, not a copy-paste solution. You should check out [the example](http://www.pantheios.org/doc/html-old/cpp_2example__cpp__custom__fe_2example__cpp__custom__fe_8cpp-example.html#a59) I've referred you to, it's much more detailed and comprehensive. Also, just from looking at the code, I see that you forgot to `#include `... – Eitan T Jun 15 '12 at 17:00
  • 1
    Yes :) I removed pantheios.1.fe.all.gcc46 from my linked libraries, took source code fe.all.c from pantheios, placed it to my project and changed function isSeverityLogged. Works great, thanks :) – user1307957 Jun 16 '12 at 13:27