Commit 1d72edcc authored by gabime's avatar gabime

clang-format

parent c29b7d22
...@@ -128,7 +128,10 @@ enum level_enum ...@@ -128,7 +128,10 @@ enum level_enum
static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES; static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES;
#if !defined(SPDLOG_SHORT_LEVEL_NAMES) #if !defined(SPDLOG_SHORT_LEVEL_NAMES)
#define SPDLOG_SHORT_LEVEL_NAMES {"T", "D", "I", "W", "E", "C", "O"} #define SPDLOG_SHORT_LEVEL_NAMES \
{ \
"T", "D", "I", "W", "E", "C", "O" \
}
#endif #endif
static const char *short_level_names[] SPDLOG_SHORT_LEVEL_NAMES; static const char *short_level_names[] SPDLOG_SHORT_LEVEL_NAMES;
......
...@@ -31,7 +31,7 @@ template<typename Mutex> ...@@ -31,7 +31,7 @@ template<typename Mutex>
class rotating_file_sink final : public base_sink<Mutex> class rotating_file_sink final : public base_sink<Mutex>
{ {
public: public:
rotating_file_sink(filename_t base_filename, std::size_t max_size, std::size_t max_files, bool rotate_on_open=false) rotating_file_sink(filename_t base_filename, std::size_t max_size, std::size_t max_files, bool rotate_on_open = false)
: base_filename_(std::move(base_filename)) : base_filename_(std::move(base_filename))
, max_size_(max_size) , max_size_(max_size)
, max_files_(max_files) , max_files_(max_files)
...@@ -150,7 +150,7 @@ using rotating_file_sink_st = rotating_file_sink<details::null_mutex>; ...@@ -150,7 +150,7 @@ using rotating_file_sink_st = rotating_file_sink<details::null_mutex>;
template<typename Factory = default_factory> template<typename Factory = default_factory>
inline std::shared_ptr<logger> rotating_logger_mt( inline std::shared_ptr<logger> rotating_logger_mt(
const std::string &logger_name, const filename_t &filename, size_t max_file_size, size_t max_files, bool rotate_on_open=false) const std::string &logger_name, const filename_t &filename, size_t max_file_size, size_t max_files, bool rotate_on_open = false)
{ {
return Factory::template create<sinks::rotating_file_sink_mt>(logger_name, filename, max_file_size, max_files, rotate_on_open); return Factory::template create<sinks::rotating_file_sink_mt>(logger_name, filename, max_file_size, max_files, rotate_on_open);
} }
......
...@@ -18,22 +18,24 @@ ...@@ -18,22 +18,24 @@
namespace spdlog { namespace spdlog {
namespace sinks { namespace sinks {
inline int syslog_level(level::level_enum l) { inline int syslog_level(level::level_enum l)
switch(l) { {
case level::off: switch (l)
case level::trace: {
case level::debug: case level::off:
return LOG_DEBUG; case level::trace:
case level::info: case level::debug:
return LOG_INFO; return LOG_DEBUG;
case level::warn: case level::info:
return LOG_WARNING; return LOG_INFO;
case level::err: case level::warn:
return LOG_ERR; return LOG_WARNING;
case level::critical: case level::err:
return LOG_CRIT; return LOG_ERR;
default: case level::critical:
throw std::invalid_argument("systemd_sink.h syslog_level()"); return LOG_CRIT;
default:
throw std::invalid_argument("systemd_sink.h syslog_level()");
} }
} }
...@@ -57,13 +59,7 @@ public: ...@@ -57,13 +59,7 @@ public:
protected: protected:
void sink_it_(const details::log_msg &msg) override void sink_it_(const details::log_msg &msg) override
{ {
if( sd_journal_print( if (sd_journal_print(syslog_level(msg.level), "%.*s", static_cast<int>(msg.payload.size()), msg.payload.data()))
syslog_level(msg.level),
"%.*s",
static_cast<int>(msg.payload.size()),
msg.payload.data()
)
)
throw spdlog_ex("Failed writing to systemd"); throw spdlog_ex("Failed writing to systemd");
} }
...@@ -76,15 +72,13 @@ using systemd_sink_st = systemd_sink<details::null_mutex>; ...@@ -76,15 +72,13 @@ using systemd_sink_st = systemd_sink<details::null_mutex>;
// Create and register a syslog logger // Create and register a syslog logger
template<typename Factory = default_factory> template<typename Factory = default_factory>
inline std::shared_ptr<logger> systemd_logger_mt( inline std::shared_ptr<logger> systemd_logger_mt(const std::string &logger_name)
const std::string &logger_name)
{ {
return Factory::template create<sinks::systemd_sink_mt>(logger_name); return Factory::template create<sinks::systemd_sink_mt>(logger_name);
} }
template<typename Factory = default_factory> template<typename Factory = default_factory>
inline std::shared_ptr<logger> systemd_logger_st( inline std::shared_ptr<logger> systemd_logger_st(const std::string &logger_name)
const std::string &logger_name)
{ {
return Factory::template create<sinks::systemd_sink_st>(logger_name); return Factory::template create<sinks::systemd_sink_st>(logger_name);
} }
......
#include "logger.h" #include "logger.h"
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
spdlog::lite::logger spdlog::create_lite(void *ctx)
spdlog::lite::logger spdlog::create_lite(void* ctx)
{ {
if(ctx) { if (ctx)
{
//.. //..
} }
auto logger_impl = spdlog::default_logger(); auto logger_impl = spdlog::default_logger();
logger_impl->set_level(spdlog::level::trace); logger_impl->set_level(spdlog::level::trace);
return spdlog::lite::logger(logger_impl); return spdlog::lite::logger(logger_impl);
} }
...@@ -3,9 +3,8 @@ ...@@ -3,9 +3,8 @@
int main() int main()
{ {
//auto l = spdlog::create_lite(); // auto l = spdlog::create_lite();
//spdlog::lite::info("HELLO info {}", 123); // spdlog::lite::info("HELLO info {}", 123);
SPDLITE_TRACE("SOME MACRO {}", 123); SPDLITE_TRACE("SOME MACRO {}", 123);
SPDLITE_INFO("SOME MACRO {}", "HHHHH"); SPDLITE_INFO("SOME MACRO {}", "HHHHH");
} }
\ No newline at end of file
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
#include "spdlog/logger.h" #include "spdlog/logger.h"
static spdlog::level::level_enum to_spdlog_level(spdlog::lite::level level) static spdlog::level::level_enum to_spdlog_level(spdlog::lite::level level)
{ {
return static_cast<spdlog::level::level_enum >(level); return static_cast<spdlog::level::level_enum>(level);
} }
static spdlog::lite::level to_lite_level(spdlog::level::level_enum level) static spdlog::lite::level to_lite_level(spdlog::level::level_enum level)
...@@ -20,7 +20,7 @@ spdlog::lite::logger::logger(std::shared_ptr<spdlog::logger> impl) ...@@ -20,7 +20,7 @@ spdlog::lite::logger::logger(std::shared_ptr<spdlog::logger> impl)
bool spdlog::lite::logger::should_log(spdlog::lite::level level) const SPDLOG_NOEXCEPT bool spdlog::lite::logger::should_log(spdlog::lite::level level) const SPDLOG_NOEXCEPT
{ {
auto spd_level = to_spdlog_level(level); auto spd_level = to_spdlog_level(level);
return impl_->should_log(spd_level);//TODO level return impl_->should_log(spd_level); // TODO level
} }
void spdlog::lite::logger::log_formatted_(spdlog::lite::level level, const fmt::memory_buffer &formatted) void spdlog::lite::logger::log_formatted_(spdlog::lite::level level, const fmt::memory_buffer &formatted)
...@@ -29,7 +29,6 @@ void spdlog::lite::logger::log_formatted_(spdlog::lite::level level, const fmt:: ...@@ -29,7 +29,6 @@ void spdlog::lite::logger::log_formatted_(spdlog::lite::level level, const fmt::
impl_->log(spd_level, spdlog::details::fmt_helper::to_string_view(formatted)); impl_->log(spd_level, spdlog::details::fmt_helper::to_string_view(formatted));
} }
void spdlog::lite::logger::log_formatted_src(const spdlog::lite::src_loc &src, spdlog::lite::level lvl, const fmt::memory_buffer &formatted) void spdlog::lite::logger::log_formatted_src(const spdlog::lite::src_loc &src, spdlog::lite::level lvl, const fmt::memory_buffer &formatted)
{ {
auto spd_level = to_spdlog_level(lvl); auto spd_level = to_spdlog_level(lvl);
...@@ -75,7 +74,6 @@ void spdlog::lite::logger::set_pattern(std::string pattern) ...@@ -75,7 +74,6 @@ void spdlog::lite::logger::set_pattern(std::string pattern)
impl_->set_pattern(std::move(pattern)); impl_->set_pattern(std::move(pattern));
} }
spdlog::lite::logger &spdlog::lite::default_logger() spdlog::lite::logger &spdlog::lite::default_logger()
{ {
static spdlog::lite::logger s_default(spdlog::default_logger()); static spdlog::lite::logger s_default(spdlog::default_logger());
......
This diff is collapsed.
...@@ -69,7 +69,7 @@ TEST_CASE("rotating_file_logger2", "[rotating_logger]]") ...@@ -69,7 +69,7 @@ TEST_CASE("rotating_file_logger2", "[rotating_logger]]")
logger->info("Test message {}", i); logger->info("Test message {}", i);
} }
// drop causes the logger destructor to be called, which is required so the // drop causes the logger destructor to be called, which is required so the
// next logger can rename the first output file. // next logger can rename the first output file.
spdlog::drop(logger->name()); spdlog::drop(logger->name());
} }
......
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