library/src/log.hpp

53 lines
1.1 KiB
C++

#ifndef LIBRARY_LOG_HPP
#define LIBRARY_LOG_HPP
#include <sstream>
#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