Skip to content
Snippets Groups Projects
Commit a178b2dc authored by Daniel Hornung's avatar Daniel Hornung
Browse files

MAINT: Renamed CAOSDB_LOG -> LOG.

parent b9aa2c79
No related branches found
No related tags found
No related merge requests found
Pipeline #10975 failed
...@@ -19,20 +19,20 @@ ...@@ -19,20 +19,20 @@
* *
*/ */
#ifndef CAOSDB_LOG_LEVELS_H #ifndef CAOSDB_LOG_LEVEL_H
#define CAOSDB_LOG_LEVELS_H #define CAOSDB_LOG_LEVEL_H
#define CAOSDB_LOG_LEVEL_OFF 1000000 #define LOG_LEVEL_OFF 1000000
#define CAOSDB_LOG_LEVEL_FATAL 700 #define LOG_LEVEL_FATAL 700
#define CAOSDB_LOG_LEVEL_ERROR 600 #define LOG_LEVEL_ERROR 600
#define CAOSDB_LOG_LEVEL_WARN 500 #define LOG_LEVEL_WARN 500
#define CAOSDB_LOG_LEVEL_INFO 400 #define LOG_LEVEL_INFO 400
#define CAOSDB_LOG_LEVEL_DEBUG 300 #define LOG_LEVEL_DEBUG 300
#define CAOSDB_LOG_LEVEL_TRACE 200 #define LOG_LEVEL_TRACE 200
#define CAOSDB_LOG_LEVEL_ALL 0 #define LOG_LEVEL_ALL 0
#ifndef CAOSDB_DEFAULT_LOG_LEVEL #ifndef DEFAULT_LOG_LEVEL
#define CAOSDB_DEFAULT_LOG_LEVEL CAOSDB_LOG_LEVEL_ERROR #define DEFAULT_LOG_LEVEL LOG_LEVEL_ERROR
#endif #endif
#endif #endif
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#ifndef CAOSDB_LOGGING_H #ifndef CAOSDB_LOGGING_H
#define CAOSDB_LOGGING_H #define CAOSDB_LOGGING_H
#include "caosdb/log_level.h" // for CAOSDB_LOG_... #include "caosdb/log_level.h" // for LOG_LEVEL...
#include "boost/log/sources/global_logger_storage.hpp" // for BOOST_LOG_I... #include "boost/log/sources/global_logger_storage.hpp" // for BOOST_LOG_I...
#include "boost/log/sources/record_ostream.hpp" // IWYU pragma: keep #include "boost/log/sources/record_ostream.hpp" // IWYU pragma: keep
#include "boost/log/sources/severity_channel_logger.hpp" // for BOOST_LOG_C... #include "boost/log/sources/severity_channel_logger.hpp" // for BOOST_LOG_C...
...@@ -162,23 +162,17 @@ void caosdb_log_trace(const char *channel, const char *msg); ...@@ -162,23 +162,17 @@ void caosdb_log_trace(const char *channel, const char *msg);
} // namespace caosdb::logging } // namespace caosdb::logging
#define CAOSDB_LOG_FATAL(Channel) \ #define LOG_FATAL(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, \ BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, LOG_LEVEL_FATAL)
CAOSDB_LOG_LEVEL_FATAL) #define LOG_ERROR(Channel) \
#define CAOSDB_LOG_ERROR(Channel) \ BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, LOG_LEVEL_ERROR)
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, \ #define LOG_WARN(Channel) \
CAOSDB_LOG_LEVEL_ERROR) BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, LOG_LEVEL_WARN)
#define CAOSDB_LOG_WARN(Channel) \ #define LOG_INFO(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, \ BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, LOG_LEVEL_INFO)
CAOSDB_LOG_LEVEL_WARN) #define LOG_DEBUG(Channel) \
#define CAOSDB_LOG_INFO(Channel) \ BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, LOG_LEVEL_DEBUG)
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, \ #define LOG_TRACE(Channel) \
CAOSDB_LOG_LEVEL_INFO) BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, LOG_LEVEL_TRACE)
#define CAOSDB_LOG_DEBUG(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, \
CAOSDB_LOG_LEVEL_DEBUG)
#define CAOSDB_LOG_TRACE(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, \
CAOSDB_LOG_LEVEL_TRACE)
#endif #endif
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include "caosdb/connection.h" // for ConnectionManager #include "caosdb/connection.h" // for ConnectionManager
#include "caosdb/constants.h" // for LIBCAOSDB_CONF... #include "caosdb/constants.h" // for LIBCAOSDB_CONF...
#include "caosdb/exceptions.h" // for ConfigurationE... #include "caosdb/exceptions.h" // for ConfigurationE...
#include "caosdb/log_level.h" // for CAOSDB_DEFAULT... #include "caosdb/log_level.h" // for DEFAULT_LOG_LE...
#include "caosdb/status_code.h" // for StatusCode #include "caosdb/status_code.h" // for StatusCode
#include "caosdb/utility.h" // for get_home_direc... #include "caosdb/utility.h" // for get_home_direc...
#include <bits/exception.h> // for exception #include <bits/exception.h> // for exception
...@@ -321,20 +321,20 @@ auto LoggingConfigurationHelper::CreateLoggingConfiguration( ...@@ -321,20 +321,20 @@ auto LoggingConfigurationHelper::CreateLoggingConfiguration(
: ""; : "";
int default_level = 0; int default_level = 0;
static std::map<std::string, int> log_level_names = { static std::map<std::string, int> log_level_names = {
{"", CAOSDB_DEFAULT_LOG_LEVEL}, {"off", CAOSDB_LOG_LEVEL_OFF}, {"", DEFAULT_LOG_LEVEL}, {"off", LOG_LEVEL_OFF},
{"fatal", CAOSDB_LOG_LEVEL_FATAL}, {"error", CAOSDB_LOG_LEVEL_ERROR}, {"fatal", LOG_LEVEL_FATAL}, {"error", LOG_LEVEL_ERROR},
{"warn", CAOSDB_LOG_LEVEL_WARN}, {"info", CAOSDB_LOG_LEVEL_INFO}, {"warn", LOG_LEVEL_WARN}, {"info", LOG_LEVEL_INFO},
{"debug", CAOSDB_LOG_LEVEL_DEBUG}, {"trace", CAOSDB_LOG_LEVEL_TRACE}, {"debug", LOG_LEVEL_DEBUG}, {"trace", LOG_LEVEL_TRACE},
{"all", CAOSDB_LOG_LEVEL_ALL}}; {"all", LOG_LEVEL_ALL}};
try { try {
default_level = CAOSDB_DEFAULT_LOG_LEVEL; default_level = DEFAULT_LOG_LEVEL;
} catch (const std::out_of_range &exc) { } catch (const std::out_of_range &exc) {
throw ConfigurationError("Unknown log level: " + default_level_str); throw ConfigurationError("Unknown log level: " + default_level_str);
} }
auto result = LoggingConfiguration(default_level); auto result = LoggingConfiguration(default_level);
if (default_level == CAOSDB_LOG_LEVEL_OFF) { if (default_level == LOG_LEVEL_OFF) {
return result; return result;
} }
...@@ -360,7 +360,7 @@ auto ConfigurationManager::mReset() noexcept -> int { ...@@ -360,7 +360,7 @@ auto ConfigurationManager::mReset() noexcept -> int {
} catch (const caosdb::exceptions::Exception &exc) { } catch (const caosdb::exceptions::Exception &exc) {
return exc.GetCode(); return exc.GetCode();
} catch (const std::exception &exc) { } catch (const std::exception &exc) {
CAOSDB_LOG_ERROR(logger_name) LOG_ERROR(logger_name)
<< "Unknown error during the reset of the ConfigurationManager: " << "Unknown error during the reset of the ConfigurationManager: "
<< exc.what(); << exc.what();
return StatusCode::CONFIGURATION_ERROR; return StatusCode::CONFIGURATION_ERROR;
...@@ -375,7 +375,7 @@ auto ConfigurationManager::mClear() noexcept -> int { ...@@ -375,7 +375,7 @@ auto ConfigurationManager::mClear() noexcept -> int {
} catch (const caosdb::exceptions::Exception &exc) { } catch (const caosdb::exceptions::Exception &exc) {
return exc.GetCode(); return exc.GetCode();
} catch (const std::exception &exc) { } catch (const std::exception &exc) {
CAOSDB_LOG_ERROR(logger_name) LOG_ERROR(logger_name)
<< "Unknown error during the reset of the ConfigurationManager: " << "Unknown error during the reset of the ConfigurationManager: "
<< exc.what(); << exc.what();
return StatusCode::CONFIGURATION_ERROR; return StatusCode::CONFIGURATION_ERROR;
...@@ -516,7 +516,7 @@ auto ConfigurationManager::InitializeDefaults() -> int { ...@@ -516,7 +516,7 @@ auto ConfigurationManager::InitializeDefaults() -> int {
logging::initialize_logging(logging_configuration); logging::initialize_logging(logging_configuration);
} else { } else {
logging::initialize_logging_defaults(); logging::initialize_logging_defaults();
CAOSDB_LOG_WARN(logger_name) << "No configuration has been found."; LOG_WARN(logger_name) << "No configuration has been found.";
} }
return 0; return 0;
......
...@@ -65,7 +65,7 @@ SinkConfiguration::SinkConfiguration(std::string name, int level) ...@@ -65,7 +65,7 @@ SinkConfiguration::SinkConfiguration(std::string name, int level)
auto SinkConfiguration::Configure(boost::log::settings &settings) const auto SinkConfiguration::Configure(boost::log::settings &settings) const
-> void { -> void {
CAOSDB_LOG_TRACE(logger_name) LOG_TRACE(logger_name)
<< "Enter SinkConfiguration::Configure(&settings)"; << "Enter SinkConfiguration::Configure(&settings)";
auto sink = "Sinks." + GetName(); auto sink = "Sinks." + GetName();
settings[sink]["Destination"] = GetDestination(); settings[sink]["Destination"] = GetDestination();
...@@ -79,14 +79,14 @@ ConsoleSinkConfiguration::ConsoleSinkConfiguration(const std::string &name, ...@@ -79,14 +79,14 @@ ConsoleSinkConfiguration::ConsoleSinkConfiguration(const std::string &name,
: SinkConfiguration(name, level) {} : SinkConfiguration(name, level) {}
[[nodiscard]] auto ConsoleSinkConfiguration::GetDestination() const [[nodiscard]] auto ConsoleSinkConfiguration::GetDestination() const
-> const std::string & { -> const std::string & {
CAOSDB_LOG_TRACE(logger_name) LOG_TRACE(logger_name)
<< "Enter ConsoleSinkConfiguration::GetDestination()"; << "Enter ConsoleSinkConfiguration::GetDestination()";
return this->destination; return this->destination;
} }
auto ConsoleSinkConfiguration::Configure(boost::log::settings &settings) const auto ConsoleSinkConfiguration::Configure(boost::log::settings &settings) const
-> void { -> void {
CAOSDB_LOG_TRACE(logger_name) LOG_TRACE(logger_name)
<< "Enter ConsoleSinkConfiguration::Configure(&settings)"; << "Enter ConsoleSinkConfiguration::Configure(&settings)";
sink_configuration::Configure(settings); sink_configuration::Configure(settings);
} }
...@@ -95,7 +95,7 @@ FileSinkConfiguration::FileSinkConfiguration(const std::string &name, int level) ...@@ -95,7 +95,7 @@ FileSinkConfiguration::FileSinkConfiguration(const std::string &name, int level)
: SinkConfiguration(name, level) {} : SinkConfiguration(name, level) {}
[[nodiscard]] auto FileSinkConfiguration::GetDestination() const [[nodiscard]] auto FileSinkConfiguration::GetDestination() const
-> const std::string & { -> const std::string & {
CAOSDB_LOG_TRACE(logger_name) LOG_TRACE(logger_name)
<< "Enter FileSinkConfiguration::GetDestination()"; << "Enter FileSinkConfiguration::GetDestination()";
return this->destination; return this->destination;
} }
...@@ -105,7 +105,7 @@ auto FileSinkConfiguration::SetDirectory(const std::string &directory) -> void { ...@@ -105,7 +105,7 @@ auto FileSinkConfiguration::SetDirectory(const std::string &directory) -> void {
auto FileSinkConfiguration::Configure(boost::log::settings &settings) const auto FileSinkConfiguration::Configure(boost::log::settings &settings) const
-> void { -> void {
CAOSDB_LOG_TRACE(logger_name) LOG_TRACE(logger_name)
<< "Enter FileSinkConfiguration::Configure(&settings)"; << "Enter FileSinkConfiguration::Configure(&settings)";
sink_configuration::Configure(settings); sink_configuration::Configure(settings);
settings["Sink." + GetName() + ".Target"] = this->directory; settings["Sink." + GetName() + ".Target"] = this->directory;
...@@ -128,7 +128,7 @@ auto initialize_logging_defaults() -> int { ...@@ -128,7 +128,7 @@ auto initialize_logging_defaults() -> int {
// now set everything up // now set everything up
const static std::vector<std::shared_ptr<SinkConfiguration>> default_sinks = { const static std::vector<std::shared_ptr<SinkConfiguration>> default_sinks = {
std::make_shared<ConsoleSinkConfiguration>("DEFAULT_SINK_1", std::make_shared<ConsoleSinkConfiguration>("DEFAULT_SINK_1",
CAOSDB_DEFAULT_LOG_LEVEL)}; DEFAULT_LOG_LEVEL)};
boost::log::settings default_settings; boost::log::settings default_settings;
...@@ -143,7 +143,7 @@ auto initialize_logging_defaults() -> int { ...@@ -143,7 +143,7 @@ auto initialize_logging_defaults() -> int {
core->add_global_attribute("TimeStamp", core->add_global_attribute("TimeStamp",
boost::log::attributes::local_clock()); boost::log::attributes::local_clock());
CAOSDB_LOG_DEBUG(logger_name) << "Initialized default settings."; LOG_DEBUG(logger_name) << "Initialized default settings.";
return 0; return 0;
} }
...@@ -151,7 +151,7 @@ auto initialize_logging_defaults() -> int { ...@@ -151,7 +151,7 @@ auto initialize_logging_defaults() -> int {
auto initialize_logging(const LoggingConfiguration &configuration) -> void { auto initialize_logging(const LoggingConfiguration &configuration) -> void {
boost::log::settings new_settings; boost::log::settings new_settings;
if (configuration.GetLevel() == CAOSDB_LOG_LEVEL_OFF) { if (configuration.GetLevel() == LOG_LEVEL_OFF) {
new_settings["Core.DisableLogging"] = true; new_settings["Core.DisableLogging"] = true;
return; return;
} else { } else {
...@@ -164,42 +164,42 @@ auto initialize_logging(const LoggingConfiguration &configuration) -> void { ...@@ -164,42 +164,42 @@ auto initialize_logging(const LoggingConfiguration &configuration) -> void {
boost::log::init_from_settings(new_settings); boost::log::init_from_settings(new_settings);
CAOSDB_LOG_DEBUG(logger_name) << "Initialized logging with custom settings."; LOG_DEBUG(logger_name) << "Initialized logging with custom settings.";
} }
void caosdb_log_fatal(const char *channel, const char *msg) { void caosdb_log_fatal(const char *channel, const char *msg) {
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), channel, BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), channel,
CAOSDB_LOG_LEVEL_FATAL) LOG_LEVEL_FATAL)
<< msg; << msg;
} }
void caosdb_log_error(const char *channel, const char *msg) { void caosdb_log_error(const char *channel, const char *msg) {
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), channel, BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), channel,
CAOSDB_LOG_LEVEL_ERROR) LOG_LEVEL_ERROR)
<< msg; << msg;
} }
void caosdb_log_warn(const char *channel, const char *msg) { void caosdb_log_warn(const char *channel, const char *msg) {
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), channel, BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), channel,
CAOSDB_LOG_LEVEL_WARN) LOG_LEVEL_WARN)
<< msg; << msg;
} }
void caosdb_log_info(const char *channel, const char *msg) { void caosdb_log_info(const char *channel, const char *msg) {
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), channel, BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), channel,
CAOSDB_LOG_LEVEL_INFO) LOG_LEVEL_INFO)
<< msg; << msg;
} }
void caosdb_log_debug(const char *channel, const char *msg) { void caosdb_log_debug(const char *channel, const char *msg) {
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), channel, BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), channel,
CAOSDB_LOG_LEVEL_DEBUG) LOG_LEVEL_DEBUG)
<< msg; << msg;
} }
void caosdb_log_trace(const char *channel, const char *msg) { void caosdb_log_trace(const char *channel, const char *msg) {
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), channel, BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), channel,
CAOSDB_LOG_LEVEL_TRACE) LOG_LEVEL_TRACE)
<< msg; << msg;
} }
......
...@@ -81,7 +81,7 @@ TEST_F(test_configuration, get_default_connection_configuration_error) { ...@@ -81,7 +81,7 @@ TEST_F(test_configuration, get_default_connection_configuration_error) {
TEST_F(test_configuration, initialize_logging) { TEST_F(test_configuration, initialize_logging) {
auto logging_configuration = auto logging_configuration =
caosdb::logging::LoggingConfiguration(CAOSDB_LOG_LEVEL_ALL); caosdb::logging::LoggingConfiguration(LOG_LEVEL_ALL);
auto console_sink = auto console_sink =
std::make_shared<caosdb::logging::ConsoleSinkConfiguration>( std::make_shared<caosdb::logging::ConsoleSinkConfiguration>(
"console", CAOSDB_DEFAULT_LOG_LEVEL); "console", CAOSDB_DEFAULT_LOG_LEVEL);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment