Commit 0440d045 authored by Pape, David (FWCC) - 139658's avatar Pape, David (FWCC) - 139658
Browse files

Parameter home of logging:setup now std::filesystem::path.

parent b2e50343
......@@ -28,7 +28,7 @@
* <tt>gitlab-hpc-runner (config | run \<script_path\> \<substage\> | cleanup)</tt>
*/
int main(int argc, char *argv[]) {
char *home = nullptr;
char *h = nullptr;
try {
std::getenv("HOME");
} catch(...) {
......@@ -36,7 +36,8 @@ int main(int argc, char *argv[]) {
return 50;
}
std::filesystem::path cfgFile = std::filesystem::path(home) / ".config"
std::filesystem::path home(h);
std::filesystem::path cfgFile = home / ".config"
/ (program_invocation_short_name + std::string(".cfg"));
libconfig::Config config;
......
......@@ -14,12 +14,12 @@
#include "spdlog/spdlog.h"
#include "spdlog/sinks/daily_file_sink.h"
int logging::setup(libconfig::Config &config, std::string home) {
int logging::setup(libconfig::Config &config, std::filesystem::path home) {
std::string logsDir;
try {
logsDir = static_cast<std::string>(config.lookup("logging_directory"));
} catch (const libconfig::SettingNotFoundException &) {
logsDir = home + "/logs";
logsDir = home / "logs";
}
int fail = ::mkdir(logsDir.c_str(), S_IRWXU | S_IRGRP | S_IXGRP); // drwxr-x---
......
#ifndef LOGGING_H
#define LOGGING_H
#include <string>
#include <filesystem>
#include "CIEnvironment.h"
#include "libconfig.h++"
......@@ -10,7 +10,6 @@
* @brief Functions related to logging.
*/
namespace logging {
// TODO: std::filesystem::path home;
/**
* @brief Sets up logging (log level, logs directory, ...).
* @param[in] config A \c libconfig::Config from which the path for log files and the log level are
......@@ -19,7 +18,7 @@ namespace logging {
* logging directory is specified.
* @return 0 on success, a non-zero number on failure.
*/
int setup(libconfig::Config &config, std::string home);
int setup(libconfig::Config &config, std::filesystem::path home);
}
#endif // LOGGING_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment