mirror of
https://github.com/gabime/spdlog.git
synced 2025-10-01 02:49:03 +08:00
wip lite
This commit is contained in:
@@ -2,22 +2,13 @@
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "spdlog/sinks/basic_file_sink.h"
|
||||
#include "spdlog/sinks/stdout_color_sinks.h"
|
||||
#include "spdlog/sinks/stdout_sinks.h"
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
// example of creating lite logger with console and file sink
|
||||
spdlite::logger spdlite::create_logger(void *ctx)
|
||||
spdlite::logger create_logger(void *ctx)
|
||||
{
|
||||
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_unique<spdlog::logger>("my-logger", spdlog::sinks_init_list{console_sink, file_sink});
|
||||
logger_impl->set_level(spdlog::level::debug);
|
||||
return spdlite::logger(std::move(logger_impl));
|
||||
return spdlite::default_logger();
|
||||
}
|
||||
|
@@ -1,19 +1,12 @@
|
||||
#include "spdlite.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
auto l = spdlite::create_logger();
|
||||
l.set_level(spdlite::level::trace);
|
||||
|
||||
l.trace_printf("Hello %s ", "GABI");
|
||||
l.info_printf("Hello %d", 12346);
|
||||
l.warn_printf("Hello %f", 12346.5656);
|
||||
l.warn("Hello {}", "LITE :) ");
|
||||
|
||||
auto l2 = l.clone("logger2");
|
||||
l2.debug("HELLO");
|
||||
|
||||
auto l3 = std::move(l);
|
||||
l3.warn("HELLO FROM L3");
|
||||
|
||||
{
|
||||
spdlite::default_logger().set_level(spdlite::level::trace);
|
||||
spdlite::trace_printf("Hello %d", 123);
|
||||
spdlite::debug_printf("Hello %d", 123);
|
||||
spdlite::info_printf("Hello %d", 123);
|
||||
spdlite::warn_printf("Hello %d", 123);
|
||||
spdlite::error_printf("Hello %d", 123);
|
||||
spdlite::critical_printf("Hello %d", 123);
|
||||
}
|
Reference in New Issue
Block a user