This commit is contained in:
gabime 2015-11-28 16:52:02 +02:00
parent 992a4e6077
commit 0f76db880e
11 changed files with 748 additions and 382 deletions

View File

@ -249,7 +249,8 @@ inline void spdlog::details::async_log_helper::push_msg(details::async_log_helpe
{ {
now = details::os::now(); now = details::os::now();
sleep_or_yield(now, last_op_time); sleep_or_yield(now, last_op_time);
} while (!_q.enqueue(std::move(new_msg))); }
while (!_q.enqueue(std::move(new_msg)));
} }
} }

View File

@ -60,7 +60,8 @@ inline spdlog::async_logger::async_logger(const std::string& logger_name,
const async_overflow_policy overflow_policy, const async_overflow_policy overflow_policy,
const std::function<void()>& worker_warmup_cb, const std::function<void()>& worker_warmup_cb,
const std::chrono::milliseconds& flush_interval_ms) : const std::chrono::milliseconds& flush_interval_ms) :
async_logger(logger_name, { async_logger(logger_name,
{
single_sink single_sink
}, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms) {} }, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms) {}

View File

@ -87,7 +87,8 @@ public:
} }
void flush() { void flush()
{
std::fflush(_fd); std::fflush(_fd);
} }

File diff suppressed because it is too large Load Diff

View File

@ -50,7 +50,8 @@ inline spdlog::logger::logger(const std::string& logger_name, sinks_init_list si
// ctor with single sink // ctor with single sink
inline spdlog::logger::logger(const std::string& logger_name, spdlog::sink_ptr single_sink) : inline spdlog::logger::logger(const std::string& logger_name, spdlog::sink_ptr single_sink) :
logger(logger_name, { logger(logger_name,
{
single_sink single_sink
}) {} }) {}
@ -314,7 +315,8 @@ inline void spdlog::logger::_set_formatter(formatter_ptr msg_formatter)
_formatter = msg_formatter; _formatter = msg_formatter;
} }
inline void spdlog::logger::flush() { inline void spdlog::logger::flush()
{
for (auto& sink : _sinks) for (auto& sink : _sinks)
sink->flush(); sink->flush();
} }

View File

@ -158,7 +158,7 @@ private:
throw spdlog_ex("logger with name " + logger_name + " already exists"); throw spdlog_ex("logger with name " + logger_name + " already exists");
_loggers[logger->name()] = logger; _loggers[logger->name()] = logger;
} }
registry_t<Mutex>(){} registry_t<Mutex>() {}
registry_t<Mutex>(const registry_t<Mutex>&) = delete; registry_t<Mutex>(const registry_t<Mutex>&) = delete;
registry_t<Mutex>& operator=(const registry_t<Mutex>&) = delete; registry_t<Mutex>& operator=(const registry_t<Mutex>&) = delete;
Mutex _mutex; Mutex _mutex;

View File

@ -75,16 +75,26 @@ private:
{ {
switch(level) switch(level)
{ {
case spdlog::level::trace: return ANDROID_LOG_VERBOSE; case spdlog::level::trace:
case spdlog::level::debug: return ANDROID_LOG_DEBUG; return ANDROID_LOG_VERBOSE;
case spdlog::level::info: return ANDROID_LOG_INFO; case spdlog::level::debug:
case spdlog::level::notice: return ANDROID_LOG_INFO; return ANDROID_LOG_DEBUG;
case spdlog::level::warn: return ANDROID_LOG_WARN; case spdlog::level::info:
case spdlog::level::err: return ANDROID_LOG_ERROR; return ANDROID_LOG_INFO;
case spdlog::level::critical: return ANDROID_LOG_FATAL; case spdlog::level::notice:
case spdlog::level::alert: return ANDROID_LOG_FATAL; return ANDROID_LOG_INFO;
case spdlog::level::emerg: return ANDROID_LOG_FATAL; case spdlog::level::warn:
default: throw spdlog_ex("Incorrect level value"); return ANDROID_LOG_WARN;
case spdlog::level::err:
return ANDROID_LOG_ERROR;
case spdlog::level::critical:
return ANDROID_LOG_FATAL;
case spdlog::level::alert:
return ANDROID_LOG_FATAL;
case spdlog::level::emerg:
return ANDROID_LOG_FATAL;
default:
throw spdlog_ex("Incorrect level value");
} }
} }