mirror of
https://github.com/gabime/spdlog.git
synced 2025-10-01 02:49:03 +08:00
Merge branch 'master' into to_level
This commit is contained in:
@@ -5,6 +5,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define SPDLOG_VERSION "0.16.3"
|
||||
|
||||
#include "tweakme.h"
|
||||
|
||||
#include <string>
|
||||
#include <initializer_list>
|
||||
#include <chrono>
|
||||
@@ -74,7 +78,7 @@ using log_err_handler = std::function<void(const std::string &err_msg)>;
|
||||
//Log level enum
|
||||
namespace level
|
||||
{
|
||||
typedef enum
|
||||
enum level_enum
|
||||
{
|
||||
trace = 0,
|
||||
debug = 1,
|
||||
@@ -83,10 +87,10 @@ typedef enum
|
||||
err = 4,
|
||||
critical = 5,
|
||||
off = 6
|
||||
} level_enum;
|
||||
};
|
||||
|
||||
#if !defined(SPDLOG_LEVEL_NAMES)
|
||||
#define SPDLOG_LEVEL_NAMES { "trace", "debug", "info", "warning", "error", "critical", "off" }
|
||||
#define SPDLOG_LEVEL_NAMES { "trace", "debug", "info", "warning", "error", "critical", "off" }
|
||||
#endif
|
||||
static const char* level_names[] SPDLOG_LEVEL_NAMES;
|
||||
|
||||
@@ -115,7 +119,6 @@ inline spdlog::level::level_enum to_level_enum(const char* name)
|
||||
using level_hasher = std::hash<int>;
|
||||
} //level
|
||||
|
||||
|
||||
//
|
||||
// Async overflow policy - block by default.
|
||||
//
|
||||
@@ -145,22 +148,24 @@ namespace os
|
||||
std::string errno_str(int err_num);
|
||||
}
|
||||
}
|
||||
class spdlog_ex: public std::exception
|
||||
class spdlog_ex : public std::exception
|
||||
{
|
||||
public:
|
||||
spdlog_ex(const std::string& msg):_msg(msg)
|
||||
explicit spdlog_ex(std::string msg) : _msg(std::move(msg))
|
||||
{}
|
||||
|
||||
spdlog_ex(const std::string& msg, int last_errno)
|
||||
{
|
||||
_msg = msg + ": " + details::os::errno_str(last_errno);
|
||||
}
|
||||
|
||||
const char* what() const SPDLOG_NOEXCEPT override
|
||||
{
|
||||
return _msg.c_str();
|
||||
}
|
||||
|
||||
private:
|
||||
std::string _msg;
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
@@ -172,5 +177,4 @@ using filename_t = std::wstring;
|
||||
using filename_t = std::string;
|
||||
#endif
|
||||
|
||||
|
||||
} //spdlog
|
||||
|
Reference in New Issue
Block a user