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
This commit is part of merge request !3. Comments created here will be created in the context of that merge request.
......@@ -19,20 +19,20 @@
*
*/
#ifndef CAOSDB_LOG_LEVELS_H
#define CAOSDB_LOG_LEVELS_H
#ifndef CAOSDB_LOG_LEVEL_H
#define CAOSDB_LOG_LEVEL_H
#define CAOSDB_LOG_LEVEL_OFF 1000000
#define CAOSDB_LOG_LEVEL_FATAL 700
#define CAOSDB_LOG_LEVEL_ERROR 600
#define CAOSDB_LOG_LEVEL_WARN 500
#define CAOSDB_LOG_LEVEL_INFO 400
#define CAOSDB_LOG_LEVEL_DEBUG 300
#define CAOSDB_LOG_LEVEL_TRACE 200
#define CAOSDB_LOG_LEVEL_ALL 0
#define LOG_LEVEL_OFF 1000000
#define LOG_LEVEL_FATAL 700
#define LOG_LEVEL_ERROR 600
#define LOG_LEVEL_WARN 500
#define LOG_LEVEL_INFO 400
#define LOG_LEVEL_DEBUG 300
#define LOG_LEVEL_TRACE 200
#define LOG_LEVEL_ALL 0
#ifndef CAOSDB_DEFAULT_LOG_LEVEL
#define CAOSDB_DEFAULT_LOG_LEVEL CAOSDB_LOG_LEVEL_ERROR
#ifndef DEFAULT_LOG_LEVEL
#define DEFAULT_LOG_LEVEL LOG_LEVEL_ERROR
#endif
#endif
......@@ -23,7 +23,7 @@
#ifndef 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/record_ostream.hpp" // IWYU pragma: keep
#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);
} // namespace caosdb::logging
#define CAOSDB_LOG_FATAL(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, \
CAOSDB_LOG_LEVEL_FATAL)
#define CAOSDB_LOG_ERROR(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, \
CAOSDB_LOG_LEVEL_ERROR)
#define CAOSDB_LOG_WARN(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, \
CAOSDB_LOG_LEVEL_WARN)
#define CAOSDB_LOG_INFO(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, \
CAOSDB_LOG_LEVEL_INFO)
#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)
#define LOG_FATAL(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, LOG_LEVEL_FATAL)
#define LOG_ERROR(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, LOG_LEVEL_ERROR)
#define LOG_WARN(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, LOG_LEVEL_WARN)
#define LOG_INFO(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, LOG_LEVEL_INFO)
#define LOG_DEBUG(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, LOG_LEVEL_DEBUG)
#define LOG_TRACE(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), Channel, LOG_LEVEL_TRACE)
#endif
......@@ -31,7 +31,7 @@
#include "caosdb/connection.h" // for ConnectionManager
#include "caosdb/constants.h" // for LIBCAOSDB_CONF...
#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/utility.h" // for get_home_direc...
#include <bits/exception.h> // for exception
......@@ -321,20 +321,20 @@ auto LoggingConfigurationHelper::CreateLoggingConfiguration(
: "";
int default_level = 0;
static std::map<std::string, int> log_level_names = {
{"", CAOSDB_DEFAULT_LOG_LEVEL}, {"off", CAOSDB_LOG_LEVEL_OFF},
{"fatal", CAOSDB_LOG_LEVEL_FATAL}, {"error", CAOSDB_LOG_LEVEL_ERROR},
{"warn", CAOSDB_LOG_LEVEL_WARN}, {"info", CAOSDB_LOG_LEVEL_INFO},
{"debug", CAOSDB_LOG_LEVEL_DEBUG}, {"trace", CAOSDB_LOG_LEVEL_TRACE},
{"all", CAOSDB_LOG_LEVEL_ALL}};
{"", DEFAULT_LOG_LEVEL}, {"off", LOG_LEVEL_OFF},
{"fatal", LOG_LEVEL_FATAL}, {"error", LOG_LEVEL_ERROR},
{"warn", LOG_LEVEL_WARN}, {"info", LOG_LEVEL_INFO},
{"debug", LOG_LEVEL_DEBUG}, {"trace", LOG_LEVEL_TRACE},
{"all", LOG_LEVEL_ALL}};
try {
default_level = CAOSDB_DEFAULT_LOG_LEVEL;
default_level = DEFAULT_LOG_LEVEL;
} catch (const std::out_of_range &exc) {
throw ConfigurationError("Unknown log level: " + default_level_str);
}
auto result = LoggingConfiguration(default_level);
if (default_level == CAOSDB_LOG_LEVEL_OFF) {
if (default_level == LOG_LEVEL_OFF) {
return result;
}
......@@ -360,7 +360,7 @@ auto ConfigurationManager::mReset() noexcept -> int {
} catch (const caosdb::exceptions::Exception &exc) {
return exc.GetCode();
} catch (const std::exception &exc) {
CAOSDB_LOG_ERROR(logger_name)
LOG_ERROR(logger_name)
<< "Unknown error during the reset of the ConfigurationManager: "
<< exc.what();
return StatusCode::CONFIGURATION_ERROR;
......@@ -375,7 +375,7 @@ auto ConfigurationManager::mClear() noexcept -> int {
} catch (const caosdb::exceptions::Exception &exc) {
return exc.GetCode();
} catch (const std::exception &exc) {
CAOSDB_LOG_ERROR(logger_name)
LOG_ERROR(logger_name)
<< "Unknown error during the reset of the ConfigurationManager: "
<< exc.what();
return StatusCode::CONFIGURATION_ERROR;
......@@ -516,7 +516,7 @@ auto ConfigurationManager::InitializeDefaults() -> int {
logging::initialize_logging(logging_configuration);
} else {
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;
......
......@@ -65,7 +65,7 @@ SinkConfiguration::SinkConfiguration(std::string name, int level)
auto SinkConfiguration::Configure(boost::log::settings &settings) const
-> void {
CAOSDB_LOG_TRACE(logger_name)
LOG_TRACE(logger_name)
<< "Enter SinkConfiguration::Configure(&settings)";
auto sink = "Sinks." + GetName();
settings[sink]["Destination"] = GetDestination();
......@@ -79,14 +79,14 @@ ConsoleSinkConfiguration::ConsoleSinkConfiguration(const std::string &name,
: SinkConfiguration(name, level) {}
[[nodiscard]] auto ConsoleSinkConfiguration::GetDestination() const
-> const std::string & {
CAOSDB_LOG_TRACE(logger_name)
LOG_TRACE(logger_name)
<< "Enter ConsoleSinkConfiguration::GetDestination()";
return this->destination;
}
auto ConsoleSinkConfiguration::Configure(boost::log::settings &settings) const
-> void {
CAOSDB_LOG_TRACE(logger_name)
LOG_TRACE(logger_name)
<< "Enter ConsoleSinkConfiguration::Configure(&settings)";
sink_configuration::Configure(settings);
}
......@@ -95,7 +95,7 @@ FileSinkConfiguration::FileSinkConfiguration(const std::string &name, int level)
: SinkConfiguration(name, level) {}
[[nodiscard]] auto FileSinkConfiguration::GetDestination() const
-> const std::string & {
CAOSDB_LOG_TRACE(logger_name)
LOG_TRACE(logger_name)
<< "Enter FileSinkConfiguration::GetDestination()";
return this->destination;
}
......@@ -105,7 +105,7 @@ auto FileSinkConfiguration::SetDirectory(const std::string &directory) -> void {
auto FileSinkConfiguration::Configure(boost::log::settings &settings) const
-> void {
CAOSDB_LOG_TRACE(logger_name)
LOG_TRACE(logger_name)
<< "Enter FileSinkConfiguration::Configure(&settings)";
sink_configuration::Configure(settings);
settings["Sink." + GetName() + ".Target"] = this->directory;
......@@ -128,7 +128,7 @@ auto initialize_logging_defaults() -> int {
// now set everything up
const static std::vector<std::shared_ptr<SinkConfiguration>> default_sinks = {
std::make_shared<ConsoleSinkConfiguration>("DEFAULT_SINK_1",
CAOSDB_DEFAULT_LOG_LEVEL)};
DEFAULT_LOG_LEVEL)};
boost::log::settings default_settings;
......@@ -143,7 +143,7 @@ auto initialize_logging_defaults() -> int {
core->add_global_attribute("TimeStamp",
boost::log::attributes::local_clock());
CAOSDB_LOG_DEBUG(logger_name) << "Initialized default settings.";
LOG_DEBUG(logger_name) << "Initialized default settings.";
return 0;
}
......@@ -151,7 +151,7 @@ auto initialize_logging_defaults() -> int {
auto initialize_logging(const LoggingConfiguration &configuration) -> void {
boost::log::settings new_settings;
if (configuration.GetLevel() == CAOSDB_LOG_LEVEL_OFF) {
if (configuration.GetLevel() == LOG_LEVEL_OFF) {
new_settings["Core.DisableLogging"] = true;
return;
} else {
......@@ -164,42 +164,42 @@ auto initialize_logging(const LoggingConfiguration &configuration) -> void {
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) {
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), channel,
CAOSDB_LOG_LEVEL_FATAL)
LOG_LEVEL_FATAL)
<< msg;
}
void caosdb_log_error(const char *channel, const char *msg) {
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), channel,
CAOSDB_LOG_LEVEL_ERROR)
LOG_LEVEL_ERROR)
<< msg;
}
void caosdb_log_warn(const char *channel, const char *msg) {
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), channel,
CAOSDB_LOG_LEVEL_WARN)
LOG_LEVEL_WARN)
<< msg;
}
void caosdb_log_info(const char *channel, const char *msg) {
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), channel,
CAOSDB_LOG_LEVEL_INFO)
LOG_LEVEL_INFO)
<< msg;
}
void caosdb_log_debug(const char *channel, const char *msg) {
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), channel,
CAOSDB_LOG_LEVEL_DEBUG)
LOG_LEVEL_DEBUG)
<< msg;
}
void caosdb_log_trace(const char *channel, const char *msg) {
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger::get(), channel,
CAOSDB_LOG_LEVEL_TRACE)
LOG_LEVEL_TRACE)
<< msg;
}
......
......@@ -81,7 +81,7 @@ TEST_F(test_configuration, get_default_connection_configuration_error) {
TEST_F(test_configuration, initialize_logging) {
auto logging_configuration =
caosdb::logging::LoggingConfiguration(CAOSDB_LOG_LEVEL_ALL);
caosdb::logging::LoggingConfiguration(LOG_LEVEL_ALL);
auto console_sink =
std::make_shared<caosdb::logging::ConsoleSinkConfiguration>(
"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