mirror of https://github.com/gabime/spdlog.git
wip lite
parent
e32c856a04
commit
c2b0e223fa
@ -1,12 +1,12 @@
|
||||
// Copyright(c) 2015-present Gabi Melman.
|
||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||
|
||||
#include "spdlite.h"
|
||||
#include "spdlite_global.h"
|
||||
|
||||
#define SPDLITE_ACTIVE_LEVEL SPDLITE_LEVEL_TRACE
|
||||
#include "spdlite_macros.h"
|
||||
int main()
|
||||
{
|
||||
spdlite::default_logger().set_level(spdlite::level::trace);
|
||||
spdlite::trace_printf("Hello %d", 123);
|
||||
spdlite::debug_printf("Hello %d", 123);
|
||||
spdlite::info_printf("Hello %d", 123);
|
||||
spdlite::warn_printf("Hello %d", 123);
|
||||
spdlite::error_printf("Hello %d", 123);
|
||||
spdlite::critical_printf("Hello %d", 123);
|
||||
{
|
||||
SPDLITE_TRACE("SOME INFO {}", 123);
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(spdlog_lite)
|
||||
|
||||
add_library(spdlog_lite spdlite.cpp spdlite.h)
|
||||
add_library(spdlog_lite spdlite.cpp spdlite.h spdlite_global.cpp spdlite_global.h spdlite_macros.h)
|
||||
|
||||
target_link_libraries(spdlog_lite spdlog::spdlog)
|
||||
|
@ -0,0 +1,63 @@
|
||||
// Copyright(c) 2015-present Gabi Melman.
|
||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||
|
||||
#include "spdlite_global.h"
|
||||
|
||||
spdlite::logger &spdlite::default_logger()
|
||||
{
|
||||
return spdlite::logger::default_logger();
|
||||
}
|
||||
|
||||
// printf
|
||||
void spdlite::log_printf(spdlite::level lvl, const char *format, va_list args)
|
||||
{
|
||||
default_logger().log_printf(lvl, format, args);
|
||||
}
|
||||
|
||||
void spdlite::trace_printf(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
log_printf(level::trace, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void spdlite::debug_printf(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
log_printf(level::debug, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void spdlite::info_printf(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
log_printf(level::info, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void spdlite::warn_printf(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
log_printf(level::warn, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void spdlite::error_printf(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
log_printf(level::err, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void spdlite::critical_printf(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
log_printf(level::critical, format, args);
|
||||
va_end(args);
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
// Copyright(c) 2015-present Gabi Melman.
|
||||
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "spdlite.h"
|
||||
namespace spdlite
|
||||
{
|
||||
//
|
||||
// spdlite namespace functions - forward the calls to the default_logger.
|
||||
//
|
||||
spdlite::logger &default_logger();
|
||||
|
||||
template<typename... Args>
|
||||
inline void trace(const char *fmt, const Args &... args)
|
||||
{
|
||||
default_logger().trace(fmt, args...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void debug(const char *fmt, const Args &... args)
|
||||
{
|
||||
default_logger().debug(fmt, args...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void info(const char *fmt, const Args &... args)
|
||||
{
|
||||
default_logger().info(fmt, args...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void warn(const char *fmt, const Args &... args)
|
||||
{
|
||||
default_logger().warn(fmt, args...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void error(const char *fmt, const Args &... args)
|
||||
{
|
||||
default_logger().error(fmt, args...);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
inline void critical(const char *fmt, const Args &... args)
|
||||
{
|
||||
default_logger().critical(fmt, args...);
|
||||
}
|
||||
|
||||
// string view convertable
|
||||
template<typename T>
|
||||
inline void trace(const T &msg)
|
||||
{
|
||||
default_logger().trace(msg);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void debug(const T &msg)
|
||||
{
|
||||
default_logger().debug(msg);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void info(const T &msg)
|
||||
{
|
||||
default_logger().info(msg);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void warn(const T &msg)
|
||||
{
|
||||
default_logger().warn(msg);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void error(const T &msg)
|
||||
{
|
||||
default_logger().error(msg);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void critical(const T &msg)
|
||||
{
|
||||
default_logger().critical(msg);
|
||||
}
|
||||
|
||||
void log_printf(spdlite::level lvl, const char *format, va_list args);
|
||||
void trace_printf(const char *format, ...);
|
||||
void debug_printf(const char *format, ...);
|
||||
void info_printf(const char *format, ...);
|
||||
void warn_printf(const char *format, ...);
|
||||
void error_printf(const char *format, ...);
|
||||
void critical_printf(const char *format, ...);
|
||||
|
||||
}
|
Loading…
Reference in New Issue