Commit 11e068d7 authored by gabime's avatar gabime

Added missing #include

parent 924ef842
//
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
......@@ -11,6 +11,10 @@
#define SPDLOG_DEBUG_ON
#include "spdlog/sinks/color_sinks.h"
#include "spdlog/async.h"
#include "spdlog/spdlog.h"
#include <iostream>
......@@ -25,13 +29,28 @@ void err_handler_example();
namespace spd = spdlog;
int main(int, char *[])
{
try
{
// Console logger with color
auto console = spdlog::console<spd::stdout_color_mt>("console");
spd::init_thread_pool(8192, 3);
auto console = spdlog::stdout_color_mt<spdlog::create_async>("console1");
auto console2 = spdlog::stderr_logger_mt<spdlog::create_async>("console2");
//auto console3 = spdlog::stdout_color_mt<spdlog::create_async>("console3");
for (int i = 0; i < 10000; i++)
{
console->info("CONSOLE1");
console2->warn("CONSOLE2");
}
spdlog::drop_all();
return 0;
console->info("Welcome to spdlog!");
console->error("Some error message with arg: {}", 1);
console->info("Welcome to spdlog!");
console->error("Some error message with arg: {}", 1);
err_handler_example();
// Formatting examples
console->warn("Easy padding in numbers like {:08d}", 12);
console->critical("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
......@@ -59,7 +78,8 @@ int main(int, char *[])
daily_logger->info(123.44);
// Customize msg format for all messages
spd::set_pattern("[%^+++%$] [%H:%M:%S %z] [thread %t] %v");
//spd::set_pattern("[%^+++%$] [%H:%M:%S %z] [thread %t] %v"); //crash
console->info("This an info message with custom format");
console->error("This an error message with custom format");
......@@ -162,6 +182,7 @@ void user_defined_example()
void err_handler_example()
{
// can be set globaly or per logger(logger->set_error_handler(..))
spdlog::set_error_handler([](const std::string &msg) { std::cerr << "my err handler: " << msg << std::endl; });
spdlog::set_error_handler([](const std::string &msg) { spd::get("console")->error("*******my err handler: {}", msg); });
spd::get("console")->info("some invalid message to trigger an error {}{}{}{}", 3);
//spd::get("console")->info("some invalid message to trigger an error {}{}{}{}", 3);
}
......@@ -27,6 +27,7 @@
<ClInclude Include="..\include\spdlog\details\pattern_formatter_impl.h" />
<ClInclude Include="..\include\spdlog\details\registry.h" />
<ClInclude Include="..\include\spdlog\details\spdlog_impl.h" />
<ClInclude Include="..\include\spdlog\details\thread_pool.h" />
<ClInclude Include="..\include\spdlog\fmt\fmt.h" />
<ClInclude Include="..\include\spdlog\fmt\ostr.h" />
<ClInclude Include="..\include\spdlog\formatter.h" />
......
......@@ -4,6 +4,7 @@
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include "stdio.h"
namespace spdlog {
namespace details {
struct console_stdout_trait
......
......@@ -13,7 +13,8 @@
// 3. Pass the formatted message to its sinks to performa the actual logging
#include "common.h"
#include "sinks/base_sink.h"
#include "sinks/sink.h"
#include "formatter.h"
#include <memory>
#include <string>
......
......@@ -5,10 +5,12 @@
#pragma once
#include "sink.h"
#include "../common.h"
#include "../details/null_mutex.h"
#include "../details/traits.h"
#include <mutex>
#include <memory>
#include <string>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment