netxsimdg
Loading...
Searching...
No Matches
Logged.hpp
Go to the documentation of this file.
1
7#ifndef SRC_INCLUDE_LOGGED_HPP
8#define SRC_INCLUDE_LOGGED_HPP
9
10#include <map>
11#include <string>
12
13namespace Nextsim {
14
16class Logged {
17public:
19 static void configure();
20 enum class level {
21 ALL,
22 TRACE,
23 DEBUG_LVL, // To avoid clashes with the DEBUG macro constant when debugging
24 INFO,
25 NOTICE,
26 WARNING,
27 ERROR,
28 CRITICAL,
29 ALERT,
30 EMERGENCY,
31 NONE
32 };
33
34 enum {
35 MINIMUM_LOG_LEVEL_KEY,
36 FILE_NAME_PATTERN_KEY,
37 CONSOLE_LOG_LEVEL_KEY,
38 };
39 static const std::map<std::string, level> levelNames;
40
48 static void log(const std::string& message, const level lvl = level::NOTICE);
54 static void trace(const std::string& message) { log(message, level::TRACE); };
63 static void debug(const std::string& message) { log(message, level::DEBUG_LVL); };
70 static void info(const std::string& message) { log(message, level::INFO); };
77 static void notice(const std::string& message) { log(message, level::NOTICE); };
84 static void warning(const std::string& message) { log(message, level::WARNING); };
91 static void error(const std::string& message) { log(message, level::ERROR); };
99 static void critical(const std::string& message) { log(message, level::CRITICAL); };
106 static void alert(const std::string& message) { log(message, level::ALERT); };
113 static void emergency(const std::string& message) { log(message, level::EMERGENCY); };
114
115protected:
116 Logged() = default;
117 // TODO: Add implementation to actually do some logging
118};
119
120} /* namespace Nextsim */
121
122#endif /* SRC_INCLUDE_LOGGED_HPP */
A class to provide general logging facilities.
Definition Logged.hpp:16
static void warning(const std::string &message)
Logs a message at level::WARNING, intended for abnormal conditions that do not affect the continuing ...
Definition Logged.hpp:84
static void configure()
Static function that configures the logger.
Definition Logged.cpp:55
static void log(const std::string &message, const level lvl=level::NOTICE)
Logs a message at the given log level, or default to level::NOTICE.
Definition Logged.cpp:71
static void error(const std::string &message)
Logs a message at level::ERROR, intended for when the model reaches an unrecoverable state.
Definition Logged.hpp:91
static void debug(const std::string &message)
Logs a message at level::DEBUG_LVL, intended for code debugging.
Definition Logged.hpp:63
static void critical(const std::string &message)
Logs a message at level::CRITICAL, intended for critical situations, including detection of problems ...
Definition Logged.hpp:99
static void alert(const std::string &message)
Logs a message at level::ALERT. Probably not needed for a geophysical model.
Definition Logged.hpp:106
static void notice(const std::string &message)
Logs a message at level::NOTICE, intended for messages that would appear during normal execution.
Definition Logged.hpp:77
static void trace(const std::string &message)
Logs a message at level::TRACE, intended for tracing code execution.
Definition Logged.hpp:54
static void info(const std::string &message)
Logs a message at level::INFO, intended for informational messages that would not normally be shown.
Definition Logged.hpp:70
static void emergency(const std::string &message)
Logs a message at level::EMERGENCY. Probably not needed for a geophysical model.
Definition Logged.hpp:113