mirror of https://github.com/gabime/spdlog.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
848 B
C++
24 lines
848 B
C++
![]()
7 years ago
|
#include "spdlite.h"
|
||
![]()
7 years ago
|
#include "spdlog/spdlog.h"
|
||
![]()
7 years ago
|
#include "spdlog/sinks/basic_file_sink.h"
|
||
|
#include "spdlog/sinks/stdout_color_sinks.h"
|
||
|
|
||
![]()
7 years ago
|
#define UNUSED(x) (void)(x)
|
||
|
|
||
|
// example of creating lite logger with console and file sink
|
||
![]()
7 years ago
|
spdlog::lite::logger spdlog::create_lite(void *ctx)
|
||
![]()
7 years ago
|
{
|
||
![]()
7 years ago
|
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);
|
||
![]()
7 years ago
|
return spdlog::lite::logger(std::move(logger_impl));
|
||
![]()
7 years ago
|
}
|