Commit f06f3f14 authored by Gabi Melman's avatar Gabi Melman Committed by GitHub

Merge pull request #468 from p-alik/master

code formatting (astyle and dos2unix)
parents 9a04e372 8fd16fc4
...@@ -36,7 +36,7 @@ int main(int, char*[]) ...@@ -36,7 +36,7 @@ int main(int, char*[])
console->info_if(i < 20, "Welcome to spdlog conditional logging!"); console->info_if(i < 20, "Welcome to spdlog conditional logging!");
console->warn_if(i != 0, "an important message"); console->warn_if(i != 0, "an important message");
console->critical_if(i != 2, "a false warning which won't show up"); console->critical_if(i != 2, "a false warning which won't show up");
// Formatting examples // Formatting examples
console->warn("Easy padding in numbers like {:08d}", 12); 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); console->critical("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
......
...@@ -88,7 +88,7 @@ inline void spdlog::async_logger::_sink_it(details::log_msg& msg) ...@@ -88,7 +88,7 @@ inline void spdlog::async_logger::_sink_it(details::log_msg& msg)
try try
{ {
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER) #if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
msg.msg_id = _msg_counter.fetch_add(1, std::memory_order_relaxed); msg.msg_id = _msg_counter.fetch_add(1, std::memory_order_relaxed);
#endif #endif
_async_log_helper->log(msg); _async_log_helper->log(msg);
if (_should_flush_on(msg)) if (_should_flush_on(msg))
......
...@@ -507,7 +507,7 @@ inline bool spdlog::logger::should_log(spdlog::level::level_enum msg_level) cons ...@@ -507,7 +507,7 @@ inline bool spdlog::logger::should_log(spdlog::level::level_enum msg_level) cons
inline void spdlog::logger::_sink_it(details::log_msg& msg) inline void spdlog::logger::_sink_it(details::log_msg& msg)
{ {
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER) #if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
msg.msg_id = _msg_counter.fetch_add(1, std::memory_order_relaxed); msg.msg_id = _msg_counter.fetch_add(1, std::memory_order_relaxed);
#endif #endif
_formatter->format(msg); _formatter->format(msg);
for (auto &sink : _sinks) for (auto &sink : _sinks)
......
...@@ -495,7 +495,7 @@ class full_formatter SPDLOG_FINAL:public flag_formatter ...@@ -495,7 +495,7 @@ class full_formatter SPDLOG_FINAL:public flag_formatter
// pattern_formatter inline impl // pattern_formatter inline impl
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
inline spdlog::pattern_formatter::pattern_formatter(const std::string& pattern, pattern_time_type pattern_time) inline spdlog::pattern_formatter::pattern_formatter(const std::string& pattern, pattern_time_type pattern_time)
: _pattern_time(pattern_time) : _pattern_time(pattern_time)
{ {
compile_pattern(pattern); compile_pattern(pattern);
} }
...@@ -665,7 +665,7 @@ inline void spdlog::pattern_formatter::handle_flag(char flag) ...@@ -665,7 +665,7 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
} }
} }
inline std::tm spdlog::pattern_formatter::get_time(details::log_msg& msg) inline std::tm spdlog::pattern_formatter::get_time(details::log_msg& msg)
{ {
if (_pattern_time == pattern_time_type::local) if (_pattern_time == pattern_time_type::local)
return details::os::localtime(log_clock::to_time_t(msg.time)); return details::os::localtime(log_clock::to_time_t(msg.time));
......
...@@ -126,7 +126,7 @@ public: ...@@ -126,7 +126,7 @@ public:
std::shared_ptr<async_logger> create_async(const std::string& logger_name, size_t queue_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function<void()>& worker_teardown_cb, sink_ptr sink) std::shared_ptr<async_logger> create_async(const std::string& logger_name, size_t queue_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function<void()>& worker_teardown_cb, sink_ptr sink)
{ {
return create_async(logger_name, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb, { sink }); return create_async(logger_name, queue_size, overflow_policy, worker_warmup_cb, flush_interval_ms, worker_teardown_cb, { sink });
} }
void formatter(formatter_ptr f) void formatter(formatter_ptr f)
......
...@@ -43,7 +43,7 @@ public: ...@@ -43,7 +43,7 @@ public:
template <typename Arg1, typename... Args> void warn(const char* fmt, const Arg1&, const Args&... args); template <typename Arg1, typename... Args> void warn(const char* fmt, const Arg1&, const Args&... args);
template <typename Arg1, typename... Args> void error(const char* fmt, const Arg1&, const Args&... args); template <typename Arg1, typename... Args> void error(const char* fmt, const Arg1&, const Args&... args);
template <typename Arg1, typename... Args> void critical(const char* fmt, const Arg1&, const Args&... args); template <typename Arg1, typename... Args> void critical(const char* fmt, const Arg1&, const Args&... args);
template <typename... Args> void log_if(const bool flag, level::level_enum lvl, const char* fmt, const Args&... args); template <typename... Args> void log_if(const bool flag, level::level_enum lvl, const char* fmt, const Args&... args);
template <typename... Args> void log_if(const bool flag, level::level_enum lvl, const char* msg); template <typename... Args> void log_if(const bool flag, level::level_enum lvl, const char* msg);
template <typename Arg1, typename... Args> void trace_if(const bool flag, const char* fmt, const Arg1&, const Args&... args); template <typename Arg1, typename... Args> void trace_if(const bool flag, const char* fmt, const Arg1&, const Args&... args);
......
...@@ -19,7 +19,7 @@ namespace sinks ...@@ -19,7 +19,7 @@ namespace sinks
/** /**
* This sink prefixes the output with an ANSI escape sequence color code depending on the severity * This sink prefixes the output with an ANSI escape sequence color code depending on the severity
* of the message. * of the message.
* If no color terminal detected, omit the escape codes. * If no color terminal detected, omit the escape codes.
*/ */
template <class Mutex> template <class Mutex>
...@@ -42,7 +42,8 @@ public: ...@@ -42,7 +42,8 @@ public:
_flush(); _flush();
} }
void set_color(level::level_enum color_level, const std::string& color) { void set_color(level::level_enum color_level, const std::string& color)
{
std::lock_guard<Mutex> lock(base_sink<Mutex>::_mutex); std::lock_guard<Mutex> lock(base_sink<Mutex>::_mutex);
colors_[color_level] = color; colors_[color_level] = color;
} }
...@@ -96,10 +97,10 @@ protected: ...@@ -96,10 +97,10 @@ protected:
_flush(); _flush();
} }
void _flush() override void _flush() override
{ {
fflush(target_file_); fflush(target_file_);
} }
FILE* target_file_; FILE* target_file_;
bool should_do_colors_; bool should_do_colors_;
std::map<level::level_enum, std::string> colors_; std::map<level::level_enum, std::string> colors_;
......
...@@ -36,14 +36,14 @@ public: ...@@ -36,14 +36,14 @@ public:
std::lock_guard<Mutex> lock(_mutex); std::lock_guard<Mutex> lock(_mutex);
_sink_it(msg); _sink_it(msg);
} }
void flush() SPDLOG_FINAL override void flush() SPDLOG_FINAL override
{ {
_flush(); _flush();
} }
protected: protected:
virtual void _sink_it(const details::log_msg& msg) = 0; virtual void _sink_it(const details::log_msg& msg) = 0;
virtual void _flush() = 0; virtual void _flush() = 0;
Mutex _mutex; Mutex _mutex;
}; };
} }
......
...@@ -44,15 +44,15 @@ protected: ...@@ -44,15 +44,15 @@ protected:
} }
} }
void _flush() override void _flush() override
{ {
std::lock_guard<Mutex> lock(base_sink<Mutex>::_mutex); std::lock_guard<Mutex> lock(base_sink<Mutex>::_mutex);
for (auto &sink : _sinks) for (auto &sink : _sinks)
sink->flush(); sink->flush();
} }
public: public:
void add_sink(std::shared_ptr<sink> sink) void add_sink(std::shared_ptr<sink> sink)
{ {
......
...@@ -33,7 +33,7 @@ public: ...@@ -33,7 +33,7 @@ public:
{ {
_file_helper.open(filename, truncate); _file_helper.open(filename, truncate);
} }
void set_force_flush(bool force_flush) void set_force_flush(bool force_flush)
{ {
_force_flush = force_flush; _force_flush = force_flush;
...@@ -46,10 +46,10 @@ protected: ...@@ -46,10 +46,10 @@ protected:
if(_force_flush) if(_force_flush)
_file_helper.flush(); _file_helper.flush();
} }
void _flush() override void _flush() override
{ {
_file_helper.flush(); _file_helper.flush();
} }
private: private:
details::file_helper _file_helper; details::file_helper _file_helper;
bool _force_flush; bool _force_flush;
...@@ -77,7 +77,7 @@ public: ...@@ -77,7 +77,7 @@ public:
_current_size = _file_helper.size(); //expensive. called only once _current_size = _file_helper.size(); //expensive. called only once
} }
protected: protected:
void _sink_it(const details::log_msg& msg) override void _sink_it(const details::log_msg& msg) override
{ {
...@@ -90,10 +90,10 @@ protected: ...@@ -90,10 +90,10 @@ protected:
_file_helper.write(msg); _file_helper.write(msg);
} }
void _flush() override void _flush() override
{ {
_file_helper.flush(); _file_helper.flush();
} }
private: private:
static filename_t calc_filename(const filename_t& filename, std::size_t index) static filename_t calc_filename(const filename_t& filename, std::size_t index)
...@@ -208,10 +208,10 @@ protected: ...@@ -208,10 +208,10 @@ protected:
_file_helper.write(msg); _file_helper.write(msg);
} }
void _flush() override void _flush() override
{ {
_file_helper.flush(); _file_helper.flush();
} }
private: private:
std::chrono::system_clock::time_point _next_rotation_tp() std::chrono::system_clock::time_point _next_rotation_tp()
......
...@@ -30,7 +30,7 @@ public: ...@@ -30,7 +30,7 @@ public:
{ {
} }
protected: protected:
void _sink_it(const details::log_msg& msg) override void _sink_it(const details::log_msg& msg) override
...@@ -38,8 +38,8 @@ protected: ...@@ -38,8 +38,8 @@ protected:
OutputDebugStringA(msg.formatted.c_str()); OutputDebugStringA(msg.formatted.c_str());
} }
void _flush() override void _flush() override
{} {}
}; };
typedef msvc_sink<std::mutex> msvc_sink_mt; typedef msvc_sink<std::mutex> msvc_sink_mt;
......
...@@ -32,11 +32,11 @@ std::string conditional_log(const bool flag, const T& what, spdlog::level::level ...@@ -32,11 +32,11 @@ std::string conditional_log(const bool flag, const T& what, spdlog::level::level
oss_logger.critical_if(flag, what); oss_logger.critical_if(flag, what);
break; break;
} }
return oss.str().substr(0, oss.str().length() - spdlog::details::os::eol_size); return oss.str().substr(0, oss.str().length() - spdlog::details::os::eol_size);
} }
template <typename Arg1, typename... Args> template <typename Arg1, typename... Args>
std::string conditional_log_varags(spdlog::level::level_enum logger_level, const bool flag, const char* fmt, const Arg1& arg1, const Args&... args) std::string conditional_log_varags(spdlog::level::level_enum logger_level, const bool flag, const char* fmt, const Arg1& arg1, const Args&... args)
{ {
std::ostringstream oss; std::ostringstream oss;
......
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