-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.cpp
More file actions
32 lines (25 loc) · 984 Bytes
/
Copy pathlog.cpp
File metadata and controls
32 lines (25 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "log.h"
Log::Log(const std::string &filename, const std::initializer_list<std::string> &chronoLog) :
logFile_(std::make_shared<spdlog::sinks::daily_file_sink_mt>(filename, 23, 59)) {
for (const auto &logName: chronoLog) {
subLog_.insert({logName, BasicLog(logName, logFile_)});
}
}
BasicLogPtr Log::get(const std::string &nameLog) {
if (subLog_.find(nameLog) == subLog_.end()) {
throw std::invalid_argument("Unknown basic log: " + nameLog);
}
return subLog_[nameLog].basicLogPtr_;
}
void Log::setFileLevel(spdlog::level::level_enum level) {
logFile_->set_level(level);
}
void Log::clear() {
logFile_->flush();
}
void Log::addLog(const std::string &name) {
subLog_[name] = BasicLog(name, logFile_);
}
BasicLogPtr standartLog = spdlog::stderr_color_mt("console");
Log::BasicLog::BasicLog(const std::string &name, const FileLogPtr &logFile) :
basicLogPtr_(std::make_shared<spdlog::logger>(name, logFile)) {}