2019-03-23 23:25:50 +08:00
|
|
|
#include "spdlite.h"
|
2019-03-23 19:31:57 +08:00
|
|
|
#include "spdlog/spdlog.h"
|
2019-03-24 01:34:50 +08:00
|
|
|
#include "spdlog/sinks/basic_file_sink.h"
|
|
|
|
#include "spdlog/sinks/stdout_color_sinks.h"
|
|
|
|
|
2019-03-24 07:18:05 +08:00
|
|
|
#define UNUSED(x) (void)(x)
|
|
|
|
|
|
|
|
// example of creating lite logger with console and file sink
|
2019-03-23 22:39:32 +08:00
|
|
|
spdlog::lite::logger spdlog::create_lite(void *ctx)
|
2019-03-23 19:31:57 +08:00
|
|
|
{
|
2019-03-24 07:18:05 +08:00
|
|
|
UNUSED(ctx);
|
|
|
|
std::shared_ptr<spdlog::logger> logger_impl;
|
|
|
|
|
|
|
|
auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt> ();
|
|
|
|
console_sink->set_level(spdlog::level::debug);
|
|
|
|
|
|
|
|
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt > ("log.txt", true);
|
|
|
|
file_sink ->set_level(spdlog::level::info);
|
|
|
|
|
|
|
|
logger_impl = std::make_shared<spdlog::logger>("my-logger", spdlog::sinks_init_list{console_sink, file_sink});
|
|
|
|
logger_impl->set_level(spdlog::level::debug);
|
2019-03-24 01:34:50 +08:00
|
|
|
return spdlog::lite::logger(std::move(logger_impl));
|
2019-03-23 19:31:57 +08:00
|
|
|
}
|