updated logger to support std::format (upgrading to gcc >13 was one of the most tedious things i've ever done)
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
|
||||
#include "LoggerService.hpp"
|
||||
|
||||
#include <chrono> // Tracking the time when the log function is called
|
||||
#include <string>
|
||||
#include <source_location>
|
||||
#include "LoggerService.hpp"
|
||||
// #include <source_location> TODO: investigate adding this back in
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
#include <algorithm>
|
||||
#include <cstdarg>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
@@ -58,8 +60,7 @@ LoggerService::~LoggerService() {
|
||||
if(outfile_) outfile_.close();
|
||||
}
|
||||
|
||||
void LoggerService::log(std::string component, LogFlag flag, std::string message, std::source_location Source) {
|
||||
|
||||
void LoggerService::write(std::string component, LogFlag flag, std::string message) {
|
||||
// check if flag is in the list of active flags
|
||||
bool culled = true;
|
||||
for(LogFlag& testFlag : activeFlags_) {
|
||||
@@ -83,14 +84,15 @@ void LoggerService::log(std::string component, LogFlag flag, std::string message
|
||||
|
||||
level = LogFlagStrings[flag];
|
||||
|
||||
// level.append(7 - level.length(), ' ') pads out the level string with whitespace so every line is aligned the same
|
||||
// it looked weird though
|
||||
// level.append(7 - level.length(), ' ') pads out the level string with whitespace so every line is aligned the sam
|
||||
finalmessage = finalmessage + "[" + level + "] ";
|
||||
finalmessage = finalmessage + message + " ";
|
||||
|
||||
/* Removed because didn't want to bother with variadics + default arguments
|
||||
if (configuration_.showSourceTrace) {
|
||||
finalmessage = finalmessage + "[Function: " + Source.function_name() + "]" + " " + "[Line: " + std::to_string(Source.line()) + "]" + " " + "[File: " + Source.file_name() + "]";
|
||||
finalmessage = finalmessage + "[Function: " + Source.function_name() + "]" + " " + "[Line: " + std::to_string(source.line()) + "]" + " " + "[File: " + source.file_name() + "]";
|
||||
}
|
||||
*/
|
||||
|
||||
if(configuration_.coutEnabled) {
|
||||
std::cout << finalmessage << std::endl;
|
||||
@@ -99,5 +101,5 @@ void LoggerService::log(std::string component, LogFlag flag, std::string message
|
||||
if(configuration_.fileEnabled) {
|
||||
outfile_ << finalmessage << std::endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user