Skip to content

Commit

Permalink
Merge pull request #37 from CDOT-CV/develop
Browse files Browse the repository at this point in the history
Logging Level Standardization and ACM Enhancements
  • Loading branch information
dan-du-car authored Oct 23, 2023
2 parents f7d6fd1 + 25db927 commit ea37f74
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 23 deletions.
4 changes: 3 additions & 1 deletion docker-compose-confluent-cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ services:
ACM_LOG_LEVEL: ${ACM_LOG_LEVEL}
CONFLUENT_KEY: ${CONFLUENT_KEY}
CONFLUENT_SECRET: ${CONFLUENT_SECRET}
restart: on-failure
aem:
build:
context: .
Expand All @@ -25,4 +26,5 @@ services:
ACM_LOG_TO_FILE: "false"
ACM_LOG_LEVEL: ${ACM_LOG_LEVEL}
CONFLUENT_KEY: ${CONFLUENT_KEY}
CONFLUENT_SECRET: ${CONFLUENT_SECRET}
CONFLUENT_SECRET: ${CONFLUENT_SECRET}
restart: on-failure
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ services:
ACM_CONFIG_FILE: adm.properties
ACM_LOG_TO_CONSOLE: "${ACM_LOG_TO_CONSOLE}"
ACM_LOG_TO_FILE: "${ACM_LOG_TO_FILE}"
ACM_LOG_LEVEL: "${ACM_LOG_LEVEL}"
ACM_LOG_LEVEL: "${ACM_LOG_LEVEL}"
restart: on-failure
2 changes: 1 addition & 1 deletion include/acmLogger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AcmLogger {
long LOG_SIZE = 1048576 * 5; ///> The size of a single log; these rotate.
int LOG_NUM = 5; ///> The number of logs to rotate.

spdlog::level::level_enum loglevel = spdlog::level::trace; ///> Log level for the logger.
spdlog::level::level_enum loglevel = spdlog::level::err; ///> Log level for the logger.

std::shared_ptr<spdlog::logger> spdlogger; ///> The spdlog logger.

Expand Down
2 changes: 1 addition & 1 deletion sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ ACM_LOG_TO_CONSOLE=
ACM_LOG_TO_FILE=

# The log level to use.
# Valid values are: "debug", "info", "warning", "error", "critical", "off"
# Valid values are: "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL", "OFF"
ACM_LOG_LEVEL=
25 changes: 15 additions & 10 deletions src/acm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ bool ASN1_Codec::topic_available( const std::string& topic ) {

RdKafka::Metadata* md; // must be freed if allocated
RdKafka::ErrorCode err = consumer_ptr->metadata( true, nullptr, &md, 5000 );
// TODO: Will throw a broker transport error (ERR__TRANSPORT = -195) if the broker is not available.

if ( err == RdKafka::ERR_NO_ERROR ) {
RdKafka::Metadata::TopicMetadataIterator it = md->topics()->begin();
Expand All @@ -308,8 +307,14 @@ bool ASN1_Codec::topic_available( const std::string& topic ) {
logger->warn("Metadata did not contain topic: " + topic);
}

} else if ( err == RdKafka::ERR__TRANSPORT) {
logger->error("cannot retrieve consumer metadata: Broker Transport Failure ");
logger->error("Container Exiting...");
std::exit(EXIT_FAILURE);
} else {
logger->error("cannot retrieve consumer metadata with error: " + err2str(err));
logger->error("Container Exiting...");
std::exit(EXIT_FAILURE);
}

if (md) {
Expand Down Expand Up @@ -430,19 +435,19 @@ bool ASN1_Codec::configure() {
}

if (optIsSet('v')) {
if ("trace" == optString('v')) {
if ("TRACE" == optString('v')) {
logger->set_level(spdlog::level::trace);
} else if ("debug" == optString('v')) {
logger->set_level(spdlog::level::trace);
} else if ("info" == optString('v')) {
logger->set_level(spdlog::level::trace);
} else if ("warning" == optString('v')) {
} else if ("DEBUG" == optString('v')) {
logger->set_level(spdlog::level::debug);
} else if ("INFO" == optString('v')) {
logger->set_level(spdlog::level::info);
} else if ("WARNING" == optString('v')) {
logger->set_level(spdlog::level::warn);
} else if ("error" == optString('v')) {
} else if ("ERROR" == optString('v')) {
logger->set_level(spdlog::level::err);
} else if ("critical" == optString('v')) {
} else if ("CRITICAL" == optString('v')) {
logger->set_level(spdlog::level::critical);
} else if ("off" == optString('v')) {
} else if ("OFF" == optString('v')) {
logger->set_level(spdlog::level::off);
} else {
logger->warn("information logger level was configured but unreadable; using default.");
Expand Down
18 changes: 9 additions & 9 deletions src/acm_blob_producer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,19 +188,19 @@ JMC: TODO: All the ASN1C variables that are normally setup do here!
bool ACMBlobProducer::configure() {

if ( optIsSet('v') ) {
if ( "trace" == optString('v') ) {
if ( "TRACE" == optString('v') ) {
logger->set_level( spdlog::level::trace );
} else if ( "debug" == optString('v') ) {
logger->set_level( spdlog::level::trace );
} else if ( "info" == optString('v') ) {
logger->set_level( spdlog::level::trace );
} else if ( "warning" == optString('v') ) {
} else if ( "DEBUG" == optString('v') ) {
logger->set_level( spdlog::level::debug );
} else if ( "INFO" == optString('v') ) {
logger->set_level( spdlog::level::info );
} else if ( "WARNING" == optString('v') ) {
logger->set_level( spdlog::level::warn );
} else if ( "error" == optString('v') ) {
} else if ( "ERROR" == optString('v') ) {
logger->set_level( spdlog::level::err );
} else if ( "critical" == optString('v') ) {
} else if ( "CRITICAL" == optString('v') ) {
logger->set_level( spdlog::level::critical );
} else if ( "off" == optString('v') ) {
} else if ( "OFF" == optString('v') ) {
logger->set_level( spdlog::level::off );
} else {
logger->warn("information logger level was configured but unreadable; using default.");
Expand Down

0 comments on commit ea37f74

Please sign in to comment.