clang-format

This commit is contained in:
gabime 2019-03-23 16:39:32 +02:00
parent 9ea6079072
commit 6b0bf33f8e
8 changed files with 183 additions and 191 deletions

View File

@ -128,7 +128,10 @@ enum level_enum
static string_view_t level_string_views[] SPDLOG_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
static const char *short_level_names[] SPDLOG_SHORT_LEVEL_NAMES;

View File

@ -18,8 +18,10 @@
namespace spdlog {
namespace sinks {
inline int syslog_level(level::level_enum l) {
switch(l) {
inline int syslog_level(level::level_enum l)
{
switch (l)
{
case level::off:
case level::trace:
case level::debug:
@ -57,13 +59,7 @@ public:
protected:
void sink_it_(const details::log_msg &msg) override
{
if( sd_journal_print(
syslog_level(msg.level),
"%.*s",
static_cast<int>(msg.payload.size()),
msg.payload.data()
)
)
if (sd_journal_print(syslog_level(msg.level), "%.*s", static_cast<int>(msg.payload.size()), msg.payload.data()))
throw spdlog_ex("Failed writing to systemd");
}
@ -76,15 +72,13 @@ using systemd_sink_st = systemd_sink<details::null_mutex>;
// Create and register a syslog logger
template<typename Factory = default_factory>
inline std::shared_ptr<logger> systemd_logger_mt(
const std::string &logger_name)
inline std::shared_ptr<logger> systemd_logger_mt(const std::string &logger_name)
{
return Factory::template create<sinks::systemd_sink_mt>(logger_name);
}
template<typename Factory = default_factory>
inline std::shared_ptr<logger> systemd_logger_st(
const std::string &logger_name)
inline std::shared_ptr<logger> systemd_logger_st(const std::string &logger_name)
{
return Factory::template create<sinks::systemd_sink_st>(logger_name);
}

View File

@ -1,15 +1,13 @@
#include "logger.h"
#include "spdlog/spdlog.h"
spdlog::lite::logger spdlog::create_lite(void *ctx)
{
if(ctx) {
if (ctx)
{
//..
}
auto logger_impl = spdlog::default_logger();
logger_impl->set_level(spdlog::level::trace);
return spdlog::lite::logger(logger_impl);
}

View File

@ -7,5 +7,4 @@ int main()
// spdlog::lite::info("HELLO info {}", 123);
SPDLITE_TRACE("SOME MACRO {}", 123);
SPDLITE_INFO("SOME MACRO {}", "HHHHH");
}

View File

@ -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));
}
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);
@ -75,7 +74,6 @@ void spdlog::lite::logger::set_pattern(std::string pattern)
impl_->set_pattern(std::move(pattern));
}
spdlog::lite::logger &spdlog::lite::default_logger()
{
static spdlog::lite::logger s_default(spdlog::default_logger());

View File

@ -73,13 +73,12 @@
#define SPDLITE_CRITICAL(...) (void)0
#endif
namespace spdlog {
class logger;
namespace lite {
enum class level{
enum class level
{
trace = SPDLITE_LEVEL_TRACE,
debug = SPDLITE_LEVEL_DEBUG,
info = SPDLITE_LEVEL_INFO,
@ -89,13 +88,15 @@ namespace spdlog {
off = SPDLITE_LEVEL_OFF
};
struct src_loc {
struct src_loc
{
const char *filename;
int line;
const char *funcname;
};
class logger {
class logger
{
public:
logger() = default;
@ -109,8 +110,10 @@ namespace spdlog {
bool should_log(spdlog::lite::level lvl) const noexcept;
template<typename... Args>
void log(spdlog::lite::level lvl, const char *fmt, const Args &... args) {
if (!should_log(lvl)) {
void log(spdlog::lite::level lvl, const char *fmt, const Args &... args)
{
if (!should_log(lvl))
{
return;
}
fmt::memory_buffer formatted_buf;
@ -118,10 +121,11 @@ namespace spdlog {
log_formatted_(lvl, formatted_buf);
}
template<typename... Args>
void log(const spdlog::lite::src_loc& src, spdlog::lite::level lvl, const char *fmt, const Args &... args) {
if (!should_log(lvl)) {
void log(const spdlog::lite::src_loc &src, spdlog::lite::level lvl, const char *fmt, const Args &... args)
{
if (!should_log(lvl))
{
return;
}
fmt::memory_buffer formatted_buf;
@ -129,7 +133,6 @@ namespace spdlog {
log_formatted_src(src, lvl, formatted_buf);
}
template<typename... Args>
void trace(const char *fmt, const Args &... args)
{
@ -191,11 +194,9 @@ namespace spdlog {
std::shared_ptr<spdlog::logger> impl_;
void log_formatted_(spdlog::lite::level lvl, const fmt::memory_buffer &formatted);
void log_formatted_src(const spdlog::lite::src_loc &src, spdlog::lite::level lvl, const fmt::memory_buffer &formatted);
};
spdlog::lite::logger &default_logger();
template<typename... Args>
void trace(const char *fmt, const Args &... args)
{
@ -231,7 +232,6 @@ namespace spdlog {
default_logger().critical(fmt, args...);
}
} // namespace lite
// factory to create lite logger