75 void set_mongo(
bool enabled = true,
string uri = "");
84 void set_file(
string filename,
bool array = false);
115 void info(ostream &out = cout) override;
131 void log(tuple<
string,
string> *message =
nullptr);
138 void log(message_type type);
152 void load_settings() override;
154 void connect_to_db();
155 void open_log_file(
string filename,
bool array = false);
156 void close_log_file();
157 void log_to_mongo(tuple<
string,
string> *message =
nullptr);
158 void log_doc_to_mongo(const std::
string &topic, const nlohmann::
json &message);
159 void log_blob_to_mongo();
160 void log_to_file(tuple<
string,
string> *message =
nullptr);
163 std::unique_ptr<Impl> _impl;
std::string name()
Returns the name of the agent.
The Logger class is responsible for logging messages to a MongoDB instance.
void info(ostream &out=cout) override
Overrides the info method from the Agent class.
void close_db()
Stops the logger.
void set_mongo(bool enabled=true, string uri="")
Sets whether logging to MongoDB is enabled or disabled.
void register_event(event_type event)
Registers the startup/shutdown of the logger.
Logger(const Logger &)=delete
string truncated_message(const string &message)
Truncates the message to the maximum length.
void log(tuple< string, string > *message=nullptr)
Logs the given message to the MongoDB instance and to the log file.
static bool has_mongo_support() noexcept
Reports whether this build can log to MongoDB.
void open_db()
Starts the logger.
void set_file(string filename, bool array=false)
Sets the file name for logging.
Logger(std::string name, std::string settings_path)
Constructs a Logger object with the specified name and settings path.
Logger & operator=(const Logger &)=delete