You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.2 KiB
56 lines
1.2 KiB
#ifndef _LOG_
|
|
#define _LOG_
|
|
|
|
#include <log/common.hpp>
|
|
#include <log/internal.hpp>
|
|
|
|
#include <util.hpp>
|
|
|
|
namespace log {
|
|
void setLevel(Level toLevel);
|
|
|
|
// Grouping by indentation
|
|
void open();
|
|
void close();
|
|
|
|
template <typename... Ts>
|
|
void log(Level atLevel, const char * format, const Ts & ... args) {
|
|
if(atLevel >= internal::level) {
|
|
std::cerr << "[" << internal::LEVEL_LABELS.at(atLevel) << "] ";
|
|
internal::printFormatted(util::lpad(format, internal::group).c_str(), args...);
|
|
std::cerr << std::endl;
|
|
}
|
|
}
|
|
|
|
// Library debug
|
|
template <typename... Ts>
|
|
void ldebug(const Ts & ... args) {
|
|
log(LDEBUG, args...);
|
|
}
|
|
|
|
template <typename... Ts>
|
|
void debug(const Ts & ... args) {
|
|
log(DEBUG, args...);
|
|
}
|
|
|
|
template <typename... Ts>
|
|
void info(const Ts & ... args) {
|
|
log(INFO, args...);
|
|
}
|
|
|
|
template <typename... Ts>
|
|
void warning(const Ts &... args) {
|
|
log(WARNING, args...);
|
|
}
|
|
|
|
template <typename... Ts>
|
|
void error(const Ts & ... args) {
|
|
log(ERROR, args...);
|
|
}
|
|
template <typename... Ts>
|
|
void critical(const Ts & ... args) {
|
|
log(CRITICAL, args...);
|
|
}
|
|
}
|
|
|
|
#endif |