Archived
1
Fork 0
This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
prism/engine/log/include/log.hpp

63 lines
1.6 KiB
C++
Raw Normal View History

2020-08-11 12:07:21 -04:00
#pragma once
#include <string_view>
#include <string>
#include <vector>
enum class System {
None,
Core,
Renderer,
Game,
File,
GFX
};
enum class Level {
Info,
Warning,
Error,
Debug
};
namespace console {
template<typename Arg>
void internal_format(std::string& msg, const Arg& arg) {
auto pos = msg.find_first_of("{}");
msg.replace(pos, 2, arg);
}
void process_message(const Level level, const System system, const std::string_view message);
template<typename... Args>
void internal_print(const Level level, const System system, const std::string_view format, Args&&... args) {
auto msg = std::string(format);
((internal_format<Args>(msg, args)), ...);
process_message(level, system, msg);
}
template<typename... Args>
void info(const System system, const std::string_view format, Args&&... args) {
internal_print(Level::Info, system, format, args...);
}
template<typename... Args>
void warning(const System system, const std::string_view format, Args&&... args) {
internal_print(Level::Warning, system, format, args...);
}
template<typename... Args>
void error(const System system, const std::string_view format, Args&&... args) {
internal_print(Level::Error, system, format, args...);
}
template<typename... Args>
void debug(const System system, const std::string_view format, Args&&... args) {
internal_print(Level::Debug, system, format, args...);
}
inline std::vector<std::string> stored_output;
}