Welcome to mirror list, hosted at ThFree Co, Russian Federation.

example.cpp « example - github.com/gabime/spdlog.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3c3782ff0e5ff5c72b3701dca476761525d01cac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)

// spdlog usage example

#include <cstdio>

#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE
#include "spdlog/spdlog.h"
#include "spdlog/async.h"
#include "spdlog/sinks/stdout_color_sinks.h"
#include "spdlog/sinks/backtrace-sink.h"

#include <vector>


using namespace spdlog::details;
using namespace spdlog::sinks;

int main(int, char *[]) {
    auto backtrack_sink = std::make_shared<backtrace_sink_mt >(spdlog::level::debug, 10);
    backtrack_sink ->add_sink(std::make_shared<stdout_color_sink_mt>());
    spdlog::logger l("loggername", backtrack_sink);
    l.set_level(spdlog::level::trace);
    //spdlog::set_backtrace(spdlog::level::warn, 16)
    for(int i = 0; i < 100; i++)
    {
        //l.log(spdlog::source_loc{__FILE__, __LINE__, "main"}, spdlog::level::debug, "Debug message #{}", i);
        SPDLOG_LOGGER_TRACE((&l), "Debug message #{}", i);
    }
    l.warn("This will trigger the log of all prev messages in the queue");
}