InitFileSink(): return name of the created file

This commit is contained in:
Alexey Rybalchenko 2020-07-09 11:51:42 +02:00
parent 2b8b257812
commit adcd48937a
2 changed files with 7 additions and 6 deletions

View File

@ -489,7 +489,7 @@ void Logger::SetConsoleColor(const bool colored)
fColored = colored; fColored = colored;
} }
void Logger::InitFileSink(const Severity severity, const string& filename, bool customizeName) string Logger::InitFileSink(const Severity severity, const string& filename, bool customizeName)
{ {
lock_guard<mutex> lock(fMtx); lock_guard<mutex> lock(fMtx);
if (fFileStream.is_open()) { if (fFileStream.is_open()) {
@ -520,15 +520,16 @@ void Logger::InitFileSink(const Severity severity, const string& filename, bool
cout << "Error opening file: " << fullName; cout << "Error opening file: " << fullName;
} }
return fullName;
} }
void Logger::InitFileSink(const string& severityStr, const string& filename, bool customizeName) string Logger::InitFileSink(const string& severityStr, const string& filename, bool customizeName)
{ {
if (fSeverityMap.count(severityStr)) { if (fSeverityMap.count(severityStr)) {
InitFileSink(fSeverityMap.at(severityStr), filename, customizeName); return InitFileSink(fSeverityMap.at(severityStr), filename, customizeName);
} else { } else {
LOG(error) << "Unknown severity setting: '" << severityStr << "', setting to default 'info'."; LOG(error) << "Unknown severity setting: '" << severityStr << "', setting to default 'info'.";
InitFileSink(Severity::info, filename); return InitFileSink(Severity::info, filename);
} }
} }

View File

@ -272,8 +272,8 @@ class Logger
static void SetConsoleColor(const bool colored = true); static void SetConsoleColor(const bool colored = true);
static void InitFileSink(const Severity severity, const std::string& filename, bool customizeName = true); static std::string InitFileSink(const Severity severity, const std::string& filename, bool customizeName = true);
static void InitFileSink(const std::string& severityStr, const std::string& filename, bool customizeName = true); static std::string InitFileSink(const std::string& severityStr, const std::string& filename, bool customizeName = true);
static void RemoveFileSink(); static void RemoveFileSink();