Merge remote-tracking branch 'upstream/master'

Conflicts:
	include/spdlog/spdlog.h
pull/73/head
Laszlo Kiss 11 years ago
commit 76ed0282a4

@ -112,7 +112,8 @@ int main(int, char*[])
// Example of user defined class with operator<<
class some_class {};
std::ostream& operator<<(std::ostream& os, const some_class&) {
std::ostream& operator<<(std::ostream& os, const some_class&)
{
return os << "some_class";
}

@ -64,11 +64,11 @@ class async_log_helper
async_msg() = default;
~async_msg() = default;
async_msg(async_msg&& other) SPDLOG_NOEXCEPT:
logger_name(std::move(other.logger_name)),
level(std::move(other.level)),
time(std::move(other.time)),
txt(std::move(other.txt))
async_msg(async_msg&& other) SPDLOG_NOEXCEPT:
logger_name(std::move(other.logger_name)),
level(std::move(other.level)),
time(std::move(other.time)),
txt(std::move(other.txt))
{}
async_msg& operator=(async_msg&& other) SPDLOG_NOEXCEPT

File diff suppressed because it is too large Load Diff

@ -478,7 +478,7 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
{
switch (flag)
{
// logger name
// logger name
case 'n':
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::name_formatter()));
break;

@ -41,7 +41,6 @@ namespace spdlog
{
namespace details
{
class registry
{
public:
@ -94,7 +93,6 @@ public:
return create(logger_name, { sink });
}
void formatter(formatter_ptr f)
{
std::lock_guard<std::mutex> lock(_mutex);
@ -103,14 +101,12 @@ public:
l.second->set_formatter(_formatter);
}
void set_pattern(const std::string& pattern)
{
std::lock_guard<std::mutex> lock(_mutex);
_formatter = std::make_shared<pattern_formatter>(pattern);
for (auto& l : _loggers)
l.second->set_formatter(_formatter);
}
void set_level(level::level_enum log_level)
@ -118,6 +114,7 @@ public:
std::lock_guard<std::mutex> lock(_mutex);
for (auto& l : _loggers)
l.second->set_level(log_level);
_level = log_level;
}
void set_async_mode(size_t q_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb)
@ -135,7 +132,6 @@ public:
_async_mode = false;
}
static registry& instance()
{
static registry s_instance;

@ -28,17 +28,13 @@
#pragma once
#include <mutex>
#include "common.h"
#include "logger.h"
namespace spdlog
{
// Return an existing logger or nullptr if a logger with such name doesn't exist.
// Examples:
//
@ -119,38 +115,43 @@ std::shared_ptr<logger> create(const std::string& logger_name, const It& sinks_b
template <typename Sink, typename... Args>
std::shared_ptr<spdlog::logger> create(const std::string& logger_name, const Args&...);
// Drop the reference to the given logger
void drop(const std::string &name);
// Drop all references
void drop_all();
//
// Trace & debug macros to be switched on/off at compile time for zero cost debug statements.
// Note: using these mactors overrides the runtime log threshold of the logger.
//
// Example:
// Macros to be display source file & line
// Trace & Debug can be switched on/off at compile time for zero cost debug statements.
//
// Enable debug macro, must be defined before including spdlog.h
// #define SPDLOG_DEBUG_ON
// include "spdlog/spdlog.h"
// Example:
// #define SPDLOG_DEBUG_ON
// include "spdlog/spdlog.h"
// SPDLOG_DEBUG(my_logger, "Some debug message {} {}", 1, 3.2);
//
#ifdef SPDLOG_TRACE_ON
#define SPDLOG_TRACE(logger, ...) logger->force_log(spdlog::level::trace, __VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
#define SPDLOG_TRACE(logger, ...) logger->trace(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
#else
#define SPDLOG_TRACE(logger, ...)
#endif
#ifdef SPDLOG_DEBUG_ON
#define SPDLOG_DEBUG(logger, ...) logger->force_log(spdlog::level::debug, __VA_ARGS__)
#define SPDLOG_DEBUG(logger, ...) logger->debug(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
#else
#define SPDLOG_DEBUG(logger, ...)
#endif
// Drop the reference to the given logger
void drop(const std::string &name);
// Drop all references
void drop_all();
#define SPDLOG_INFO(logger, ...) logger->info(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
#define SPDLOG_NOTICE(logger, ...) logger->notice(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
#define SPDLOG_WARN(logger, ...) logger->warn(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
#define SPDLOG_ERROR(logger, ...) logger->err(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
#define SPDLOG_CRITICAL(logger, ...) logger->critical(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
#define SPDLOG_ALERT(logger, ...) logger->alert(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
#define SPDLOG_EMERG(logger, ...) logger->emerg(__VA_ARGS__) << " (" << __FILE__ << " #" << __LINE__ <<")";
}

Loading…
Cancel
Save