56 std::string
Debug::log(
const std::string &_type,
const std::string &_msg,
unsigned int _level)
59 std::string type = _type;
61 std::transform(type.begin(), type.end(), type.begin(), ::toupper);
67 msg +=
"[ " + this->
settings.startMsg + type + (this->
settings.debugID ? +
" | " + this->
id :
"");
72 timeUtils::TimeInfo timeInfo;
73 timeUtils::DateInfo dateInfo;
74 timeUtils::Time time(
"debug-time");
76 time.update(timeInfo);
77 time.update(dateInfo);
79 msg +=
" | " + std::to_string(dateInfo.year) +
"-" + std::to_string(dateInfo.month) +
"-" + std::to_string(dateInfo.day) +
" | ";
80 msg += std::to_string(timeInfo.hour) +
":" + std::to_string(timeInfo.min) +
":" + std::to_string(timeInfo.sec) +
"." + std::to_string(timeInfo.ms)
81 + (this->
settings.timeZone ?
" +" + std::to_string(time.getUTCOffset().hour) +
":" + std::to_string(time.getUTCOffset().min) :
"");
95 if ((!this->
settings.logLevelIgnoreOutput && this->settings.logLevel == 0) ||
96 (this->settings.logLevel > 0 && _level <= this->
settings.logLevel))
104 if ((!this->
settings.logLevelIgnoreSave && this->settings.logLevel == 0) ||
105 (this->settings.logLevel > 0 && _level <= this->
settings.logLevel))
107# ifndef __PD_NO_FULL_SUPPORT
108 if (!fs::exists(fs::path(this->
settings.filePath).parent_path()))
110 fs::create_directories(fs::path(this->
settings.filePath).parent_path());
112 this->
file->close(); this->
file->open(this->
settings.filePath, this->settings.openMode);
std::string log(const std::string &_type, const std::string &_msg, unsigned int _level=0)
Log the message with specific custom type, message and log level.
Debug(const std::string &_id, const pd::DebugSettings &_settings)
Construct the debugger with specified ID and settings Call the inner __init() function to Initialize.