error handling for log file handle
parent
79bc82e365
commit
004addd2b4
|
@ -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));
|
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
|
* @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)
|
std::string Conf::prepend_project_root( std::string relative_path)
|
||||||
{
|
{
|
||||||
|
removeTrailingSlash(relative_path);
|
||||||
return this->project_root + "/" + relative_path;
|
return this->project_root + "/" + relative_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,6 +266,7 @@ Shell Conf::get_shell_by_name( std::string name ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Conf
|
* @class Conf
|
||||||
* @brief Loads the configuration for the application
|
* @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.
|
// convert to an absolute path after all the interpolation is done.
|
||||||
this->project_root = get_absolute_path( this->project_root );
|
this->project_root = get_absolute_path( this->project_root );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// all other paths are relative to project_root
|
// all other paths are relative to project_root
|
||||||
set_object_s_derivedpath( "units_path", this->units_path, filename );
|
set_object_s_derivedpath( "units_path", this->units_path, filename );
|
||||||
set_object_s_derivedpath( "logs_path", this->logs_path, filename );
|
set_object_s_derivedpath( "logs_path", this->logs_path, filename );
|
||||||
|
|
|
@ -118,6 +118,16 @@ int exec_pty(
|
||||||
FILE * stdout_log_fh = fopen( stdout_log_file.c_str(), "a+" );
|
FILE * stdout_log_fh = fopen( stdout_log_file.c_str(), "a+" );
|
||||||
FILE * stderr_log_fh = fopen( stderr_log_file.c_str(), "a+" );
|
FILE * stderr_log_fh = fopen( stderr_log_file.c_str(), "a+" );
|
||||||
|
|
||||||
|
if ( stdout_log_fh == NULL ) {
|
||||||
|
safe_perror( "Error opening STDOUT log file. Aborting.", &ttyOrig );
|
||||||
|
exit( 1 );
|
||||||
|
}
|
||||||
|
if ( stderr_log_fh == NULL ) {
|
||||||
|
safe_perror( "Error opening STDERR log file. Aborting.", &ttyOrig );
|
||||||
|
exit( 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// create the pipes for the child process to write and read from using its stderr
|
// create the pipes for the child process to write and read from using its stderr
|
||||||
int fd_child_stderr_pipe[2];
|
int fd_child_stderr_pipe[2];
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ void Suite::get_units_from_dir( std::vector<std::string> * files, std::string pa
|
||||||
// you want here. Something like:
|
// you want here. Something like:
|
||||||
if ( strstr( hFile->d_name, ".units" ))
|
if ( strstr( hFile->d_name, ".units" ))
|
||||||
{
|
{
|
||||||
std::string full_path = path + hFile->d_name;
|
std::string full_path = path + "/" + hFile->d_name;
|
||||||
files->push_back( full_path );
|
files->push_back( full_path );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue