library/src/log.hpp

53 lines
1.1 KiB
C++
Raw Normal View History

#ifndef LIBRARY_LOG_HPP
#define LIBRARY_LOG_HPP
#include <sstream>
2019-11-13 15:42:04 +01:00
#include <string>
namespace vkvm {
enum LogLevel{
DEBUG = 1,
INFO = 2,
WARNING = 3,
ERROR = 4,
CRITICAL = 5,
OFF = 6
};
/**
* log the messgae with logLevel and timestamp
* @author Julian Hinxlage
* @since 0.1.0
*/
auto log(LogLevel level, const std::string &msg) -> void;
template<typename T>
static auto buildString(std::stringstream &stream, T t) -> void {
stream << t;
}
template<typename T, typename... Ts>
static auto buildString(std::stringstream &stream, T t, Ts... ts) -> void {
stream << t;
buildString(stream, ts...);
}
template<typename... T>
static auto log(LogLevel level, T... t) -> void {
std::stringstream stream;
buildString(stream, t...);
log(level, stream.str());
}
/**
* set the logLevel, the log function will use this to determine if the message is logged
* @author Julian Hinxlage
* @since 0.1.0
*/
auto setLogLevel(LogLevel level) -> void;
}
#endif