Exemplo n.º 1
0
 void log_write(int level, const char *fmt, ...) {
     if (!g_logger.Enabled(level)) return;
     va_list ap;
     va_start(ap, fmt);
     g_logger.Logv(level, fmt, ap);
     va_end(ap);
 }
Exemplo n.º 2
0
int main() {
    Logger l;
    auto r = l.Open("stdout", Logger::kLevelDebug, 1);
    assert(r== true && "open failed");

    l.SetThreadName("main");


    l.Logv(Logger::kLevelTrace, "hello %s", "world");
    l.Logv(Logger::kLevelDebug, "hello %s", "world");

    std::thread t([&](){
            l.Logv(Logger::kLevelWarn, "hello %s", "world");
            l.SetThreadName("thread-1");
            l.Logv(Logger::kLevelWarn, "hello with name: %s", "world");
        });

    t.join();

    log_open("stdout", Logger::kLevelDebug, 1);
    log_info("hello %s", "world");
}