2014-10-11 02:37:33 +08:00
|
|
|
#pragma once
|
|
|
|
|
2014-10-24 06:59:39 +08:00
|
|
|
#include<initializer_list>
|
|
|
|
#include<chrono>
|
|
|
|
|
2014-10-31 07:13:27 +08:00
|
|
|
namespace spdlog
|
2014-10-11 02:37:33 +08:00
|
|
|
{
|
2014-10-24 06:59:39 +08:00
|
|
|
class formatter;
|
2014-11-01 08:28:49 +08:00
|
|
|
namespace sinks
|
|
|
|
{
|
2014-10-24 06:59:39 +08:00
|
|
|
class sink;
|
|
|
|
}
|
2014-10-11 02:37:33 +08:00
|
|
|
|
2014-10-24 06:59:39 +08:00
|
|
|
// Common types across the lib
|
2014-10-11 02:37:33 +08:00
|
|
|
using log_clock = std::chrono::system_clock;
|
2014-10-24 06:59:39 +08:00
|
|
|
using sink_ptr = std::shared_ptr < sinks::sink > ;
|
|
|
|
using sinks_init_list = std::initializer_list < sink_ptr > ;
|
2014-10-31 07:13:27 +08:00
|
|
|
using formatter_ptr = std::shared_ptr<spdlog::formatter>;
|
2014-10-24 06:59:39 +08:00
|
|
|
|
|
|
|
//Log level enum
|
2014-10-11 02:37:33 +08:00
|
|
|
namespace level
|
|
|
|
{
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
TRACE,
|
|
|
|
DEBUG,
|
|
|
|
INFO,
|
2014-10-24 23:01:11 +08:00
|
|
|
WARN,
|
|
|
|
ERR,
|
2014-10-11 02:37:33 +08:00
|
|
|
CRITICAL,
|
2014-10-31 07:13:27 +08:00
|
|
|
ALWAYS,
|
|
|
|
OFF
|
2014-10-11 02:37:33 +08:00
|
|
|
} level_enum;
|
|
|
|
|
2014-10-31 07:13:27 +08:00
|
|
|
static const char* level_names[] { "trace", "debug", "info", "warning", "error", "critical", "", ""};
|
|
|
|
inline const char* to_str(spdlog::level::level_enum l)
|
2014-10-11 02:37:33 +08:00
|
|
|
{
|
|
|
|
return level_names[l];
|
|
|
|
}
|
|
|
|
} //level
|
2014-10-26 07:29:50 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Log exception
|
|
|
|
//
|
2014-10-31 09:17:40 +08:00
|
|
|
class spdlog_ex : public std::exception
|
2014-10-26 07:29:50 +08:00
|
|
|
{
|
|
|
|
public:
|
2014-10-31 09:17:40 +08:00
|
|
|
spdlog_ex(const std::string& msg) :_msg(msg) {};
|
2014-11-01 08:28:49 +08:00
|
|
|
const char* what() const throw() override
|
|
|
|
{
|
2014-10-26 07:29:50 +08:00
|
|
|
return _msg.c_str();
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
std::string _msg;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2014-10-31 07:13:27 +08:00
|
|
|
} //spdlog
|