Antares Xpansion
Investment simulations for Antares studies
Loading...
Searching...
No Matches
LoggerFactories.h
1
2#ifndef ANTARESXPANSION_LOGGERFACTORIES_H
3#define ANTARESXPANSION_LOGGERFACTORIES_H
4
5#include <filesystem>
6
7#include "BendersFactory.h"
8#include "antares-xpansion/xpansion_interfaces/ILogger.h"
9#include "antares-xpansion/benders/benders_core/SimulationOptions.h"
10#include "antares-xpansion/benders/logger/Master.h"
11#include "antares-xpansion/benders/logger/MathLogger.h"
12#include "antares-xpansion/benders/logger/UserFile.h"
13Logger build_void_logger();
14
16 private:
17 Logger logger;
18
19 public:
21 const std::filesystem::path &report_file_path_string,
22 bool expert_log_at_console) {
23 auto masterLogger = std::make_shared<xpansion::logger::Master>();
24 auto user_file =
25 std::make_shared<xpansion::logger::UserFile>(report_file_path_string);
26 masterLogger->addLogger(user_file);
27
28 if (!expert_log_at_console) {
29 auto loggerUser = std::make_shared<xpansion::logger::User>(std::cout);
30 masterLogger->addLogger(loggerUser);
31 }
32
33 logger = masterLogger;
34 }
35 inline Logger get_logger() const { return logger; }
36};
37
39 private:
40 MathLoggerDriver math_logger_driver;
41
42 public:
43 explicit MathLoggerFactory(
44 const BENDERSMETHOD &method, bool console_log,
45 const std::filesystem::path &math_logs_file_path = "") {
46 if (math_logs_file_path != "") {
47 auto math_logger_file =
48 std::make_shared<MathLoggerFile>(method, math_logs_file_path);
49 math_logger_driver.add_logger(math_logger_file);
50 }
51
52 if (console_log) {
53 auto math_logger_ostream = std::make_shared<MathLoggerOstream>(method);
54
55 math_logger_driver.add_logger(math_logger_ostream);
56 }
57 }
58 explicit MathLoggerFactory() = default;
59 std::shared_ptr<MathLoggerDriver> get_logger() {
60 return std::make_shared<MathLoggerDriver>(math_logger_driver);
61 }
62 static std::shared_ptr<MathLoggerDriver> get_void_logger() {
63 return std::make_shared<MathLoggerDriver>();
64 }
65 };
66#endif // ANTARESXPANSION_LOGGERFACTORIES_H
Definition LoggerFactories.h:15
Definition BendersMathLogger.h:185
Definition LoggerFactories.h:38