error handling for log file handle

This commit is contained in:
phanes committed 2023-02-16 03:49:56 -05:00
1 parent 79bc82e365
commit 004addd2b4
3 files changed
+21 -1

No files matched your search

+10
View File
@@ -134,6 +134,12 @@ void Conf::set_object_b(std::string keyname, bool & object_member, std::string f
this->slog.log_task( E_DEBUG, "SET_PROPERTY", "'" + keyname + "' " + std::to_string(object_member));
}
void removeTrailingSlash(std::string &str) {
if (!str.empty() && str.back() == '/') {
str.pop_back();
}
}
/**
* @brief Prepend the project root to a relative path
*
@@ -147,6 +153,7 @@ void Conf::set_object_b(std::string keyname, bool & object_member, std::string f
*/
std::string Conf::prepend_project_root( std::string relative_path)
{
removeTrailingSlash(relative_path);
return this->project_root + "/" + relative_path;
}
@@ -259,6 +266,7 @@ Shell Conf::get_shell_by_name( std::string name ) {
}
/**
* @class Conf
* @brief Loads the configuration for the application
@@ -301,6 +309,8 @@ Conf::Conf(std::string filename, int LOG_LEVEL ): JSON_Loader(LOG_LEVEL ), slog(
// convert to an absolute path after all the interpolation is done.
this->project_root = get_absolute_path( this->project_root );
// all other paths are relative to project_root
set_object_s_derivedpath( "units_path", this->units_path, filename );
set_object_s_derivedpath( "logs_path", this->logs_path, filename );