spdlog/example/example.cpp

38 lines
965 B
C++
Raw Normal View History

2019-03-24 06:40:27 +08:00
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
2019-05-12 22:05:14 +08:00
2019-03-24 06:40:27 +08:00
// spdlog usage example
2019-12-13 22:17:09 +08:00
#include <cstdio>
2020-03-06 21:21:21 +08:00
void load_levels_example();
2019-12-13 22:17:09 +08:00
void stdout_logger_example();
void basic_example();
void rotating_example();
void daily_example();
void async_example();
void binary_example();
2020-08-29 07:48:43 +08:00
void stopwatch_example();
2019-12-13 22:17:09 +08:00
void trace_example();
void multi_sink_example();
void user_defined_example();
void err_handler_example();
void syslog_example();
void custom_flags_example();
2019-12-13 22:17:09 +08:00
2019-12-23 02:40:19 +08:00
#include "spdlog/spdlog.h"
2020-03-16 00:56:38 +08:00
#include "spdlog/cfg/env.h" // for loading levels from the environment variable
2020-09-26 20:06:53 +08:00
#include "spdlog/sinks/stdout_color_sinks.h"
2019-08-23 00:58:49 +08:00
2020-02-27 01:21:36 +08:00
int main(int, char *[])
2019-12-08 23:08:20 +08:00
{
2020-03-06 21:21:21 +08:00
// Log levels can be loaded from argv/env using "SPDLOG_LEVEL"
spdlog::cfg::load_env_levels();
2020-09-26 20:06:53 +08:00
spdlog::info("Default logger");
auto l1 = spdlog::stdout_color_mt("l1");
auto l2 = spdlog::stdout_color_mt("l2");
2020-03-21 21:25:26 +08:00
2020-09-26 20:06:53 +08:00
l1->debug("L1");
l2->trace("L2");
}