56 lines
1.7 KiB
C++
56 lines
1.7 KiB
C++
// Josh's Logger
|
|
// Minimal, robust, Modern (C++20) Logging Framework
|
|
// Created by Joshua O'Leary @ Redacted Software, June 2024
|
|
// Contact: josh@redacted.cc
|
|
// Contributors: william@redacted.cc maxi@redacted.cc
|
|
// This work is dedicated to the public domain.
|
|
|
|
#include <jlog/jlog.hpp>
|
|
|
|
// Writing custom wrappers for jlog is super easy!
|
|
/*void coollog(std::vector<jlog::token> tokens) {
|
|
std::vector<jlog::token> wtokens;
|
|
auto group = jlog::token{.content = "COOLLOGGER"};
|
|
wtokens.push_back(group);
|
|
wtokens.insert(wtokens.end(), tokens.begin(), tokens.end());
|
|
jlog::log(wtokens);
|
|
}*/
|
|
|
|
// We can either define custom logging macros or redefine jlog's builtin macros.
|
|
//#define COOLINFO(i) coollog(jlog::info_format(i));
|
|
//#define COOLINFOTRACE(i) coollog(jlog::info_detailed_format(i, FUNCTION, __FILE__, __LINE__));
|
|
|
|
int main()
|
|
{
|
|
LOGLEVEL(jlog::severity::debug); // <- see jlog::severity for full list of log levels
|
|
CONSOLELOGGING(true); // <- Set to true or false to enable/disable logging to console. Useful for release builds of a program.
|
|
#ifdef _WIN32
|
|
jlog::set_default_logfile("NUL");
|
|
#else
|
|
jlog::set_default_logfile("/dev/null");
|
|
#endif
|
|
|
|
INFO("This is barely useful information.");
|
|
DEBUG("Debugging Information");
|
|
VERBOSE("Yadda Yadda Yadda");
|
|
WARNING("Slight miscalculation!");
|
|
ERROR("Oops, something went wrong.");
|
|
FATAL("Unrecoverable Error!!!");
|
|
|
|
//COOLINFO("This is really cool!!!");
|
|
//COOLINFOTRACE("THIS IS EVEN COOLER!!!");
|
|
|
|
LOGTEST("This is a really cool test man :3");
|
|
LOGTEST("Go check cmake-build-debug/logtest.log and cmake-build-debug/latest.log");
|
|
|
|
return 0;
|
|
}
|
|
|
|
//Windows :(
|
|
#ifdef _WIN32
|
|
extern "C" {
|
|
int wmain(int argc, wchar_t* argv[]) {
|
|
return main();
|
|
}
|
|
}
|
|
#endif |