lcpex rewrite - alpha

This commit is contained in:
phanes
2023-02-15 18:44:21 -05:00
parent bb85754dc0
commit 7ed6e13fa5
82 changed files with 4510 additions and 2592 deletions

58
src/logger/Logger.cpp Normal file
View File

@@ -0,0 +1,58 @@
/*
Rex - A configuration management and workflow automation tool that
compiles and runs in minimal environments.
© SILO GROUP and Chris Punches, 2020.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "Logger.h"
Logger::Logger( int LOG_LEVEL, std::string mask )
{
this->LOG_LEVEL = LOG_LEVEL;
this->mask = mask;
}
void Logger::log( int LOG_LEVEL, std::string msg )
{
std::string ERR = "XXXX";
if ( LOG_LEVEL <= this->LOG_LEVEL )
{
switch ( LOG_LEVEL )
{
case E_DEBUG: ERR = "DBUG"; break;
case E_FATAL: ERR = "FATL"; break;
case E_INFO: ERR = "INFO"; break;
case E_WARN: ERR = "WARN"; break;
}
std::string s_msg = "[" + ERR + "] " + msg;
if ( LOG_LEVEL == E_FATAL | LOG_LEVEL == E_WARN )
{
std::cerr << "[" << get_8601() << "] [" << ERR << "] " << "[" << this->mask << "] " << msg.c_str() << std::endl;
} else {
std::cout << "[" << get_8601() << "] [" << ERR << "] " << "[" << this->mask << "] " << msg.c_str() << std::endl;
}
}
}
void Logger::log_task( int LOG_LEVEL, std::string task_name, std::string msg )
{
std::string final_msg = "[" + task_name + "] " + msg;
this->log( LOG_LEVEL, final_msg );
}