clang-format

This commit is contained in:
gabime 2019-03-24 00:41:22 +02:00
parent 934cc892eb
commit bac1e4a850
4 changed files with 23 additions and 30 deletions

View File

@ -70,7 +70,7 @@ int main(int, char *[])
spdlog::shutdown();
}
// Exceptions will only be thrown upon failed logger or sink construction (not during logging).
// Exceptions will only be thrown upon failed logger or sink construction (not during logging).
catch (const spdlog::spdlog_ex &ex)
{
std::printf("Log initialization failed: %s\n", ex.what());

View File

@ -5,7 +5,7 @@ int main()
auto l = spdlog::create_lite();
l.set_level(spdlog::lite::level::trace);
l.trace_f("Hello %s ","GABI");
l.trace_f("Hello %s ", "GABI");
l.info_f("Hello %d", 12346);
l.warn_f("Hello %f", 12346.5656);
l.warn("Hello {}", 12346.5656);

View File

@ -28,65 +28,63 @@ void spdlog::lite::logger::log(spdlog::lite::level lvl, const string_view_t &sv)
impl_->log(spd_level, sv);
}
void spdlog::lite::logger::log_printf(spdlog::lite::level lvl, const char* format, va_list args)
void spdlog::lite::logger::log_printf(spdlog::lite::level lvl, const char *format, va_list args)
{
char buffer[500];
auto size = vsnprintf (buffer, sizeof(buffer),format, args);
if(size < 0)
auto size = vsnprintf(buffer, sizeof(buffer), format, args);
if (size < 0)
{
size = snprintf(buffer, sizeof(buffer), "invalid format (%s)", format);
}
log(lvl, string_view_t{buffer, static_cast<size_t>(size)});
}
void spdlog::lite::logger::trace_f(const char *format, ...)
{
va_list args;
va_start (args, format);
va_start(args, format);
log_printf(lite::level::trace, format, args);
va_end (args);
va_end(args);
}
void spdlog::lite::logger::debug_f(const char *format, ...)
{
va_list args;
va_start (args, format);
va_start(args, format);
log_printf(lite::level::debug, format, args);
va_end (args);
va_end(args);
}
void spdlog::lite::logger::info_f(const char *format, ...)
{
va_list args;
va_start (args, format);
va_start(args, format);
log_printf(lite::level::info, format, args);
va_end (args);
va_end(args);
}
void spdlog::lite::logger::warn_f(const char *format, ...)
{
va_list args;
va_start (args, format);
va_start(args, format);
log_printf(lite::level::warn, format, args);
va_end (args);
va_end(args);
}
void spdlog::lite::logger::error_f(const char *format, ...)
{
va_list args;
va_start (args, format);
va_start(args, format);
log_printf(lite::level::err, format, args);
va_end (args);
va_end(args);
}
void spdlog::lite::logger::critical_f(const char *format, ...)
{
va_list args;
va_start (args, format);
va_start(args, format);
log_printf(lite::level::critical, format, args);
va_end (args);
va_end(args);
}
void spdlog::lite::logger::set_level(spdlog::lite::level level)
@ -138,5 +136,3 @@ spdlog::lite::logger &spdlog::lite::default_logger()
static spdlog::lite::logger s_default(spdlog::default_logger());
return s_default;
}

View File

@ -31,7 +31,6 @@ enum class level
off
};
class logger
{
public:
@ -60,7 +59,7 @@ public:
// log string view
void log(spdlog::lite::level lvl, const string_view_t &sv);
void log_printf(spdlog::lite::level lvl, const char* format, va_list args);
void log_printf(spdlog::lite::level lvl, const char *format, va_list args);
//
// trace
@ -76,7 +75,7 @@ public:
log(spdlog::lite::level::trace, fmt, args...);
}
void trace_f(const char *printf_format, ...);
void trace_f(const char *printf_format, ...);
//
// debug
@ -92,7 +91,7 @@ public:
log(spdlog::lite::level::debug, fmt, args...);
}
void debug_f(const char *printf_format, ...);
void debug_f(const char *printf_format, ...);
//
// info
@ -124,7 +123,7 @@ public:
log(spdlog::lite::level::warn, fmt, args...);
}
void warn_f(const char *printf_format, ...);
void warn_f(const char *printf_format, ...);
//
// error
@ -134,14 +133,13 @@ public:
log(spdlog::lite::level::err, string_view_t(msg));
}
template<typename... Args>
void error(const char *fmt, const Args &... args)
{
log(spdlog::lite::level::err, fmt, args...);
}
void error_f(const char *printf_format, ...);
void error_f(const char *printf_format, ...);
//
// critical
@ -157,7 +155,7 @@ public:
log(spdlog::lite::level::critical, fmt, args...);
}
void critical_f(const char *printf_format, ...);
void critical_f(const char *printf_format, ...);
//
// setters/getters
@ -177,7 +175,6 @@ public:
protected:
std::shared_ptr<spdlog::logger> impl_;
void log_formatted_(spdlog::lite::level lvl, const fmt::memory_buffer &formatted);
};
spdlog::lite::logger &default_logger();