Skip to content

Commit

Permalink
Move essential log messages up to WARN level
Browse files Browse the repository at this point in the history
This lets users enjoy a much quieter JANA by setting `-Pjana:loglevel=warn`.
  • Loading branch information
nathanwbrei committed Sep 15, 2024
1 parent 88279e9 commit 5b6e9a5
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 28 deletions.
10 changes: 5 additions & 5 deletions src/libraries/JANA/CLI/JSignalHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ std::atomic_int g_thread_report_count;

void create_named_pipe(const std::string& path_to_named_pipe) {

LOG_INFO(*g_logger) << "Creating pipe named \"" << g_path_to_named_pipe
LOG_WARN(*g_logger) << "Creating pipe named \"" << g_path_to_named_pipe
<< "\" for status info." << LOG_END;

mkfifo(path_to_named_pipe.c_str(), 0666);
Expand All @@ -41,7 +41,7 @@ void send_to_named_pipe(const std::string& path_to_named_pipe, const std::string
close(fd);
}
else {
LOG_WARN(*g_logger) << "Unable to open named pipe '" << g_path_to_named_pipe << "' for writing. \n"
LOG_ERROR(*g_logger) << "Unable to open named pipe '" << g_path_to_named_pipe << "' for writing. \n"
<< " You can use a different named pipe for status info by setting the parameter `jana:status_fname`.\n"
<< " The status report will still show up in the log." << LOG_END;
}
Expand Down Expand Up @@ -131,7 +131,7 @@ void handle_usr2(int) {
void handle_sigsegv(int /*signal_number*/, siginfo_t* /*signal_info*/, void* /*context*/) {
LOG_FATAL(*g_logger) << "Segfault detected! Printing backtraces and exiting." << LOG_END;
auto report = produce_overall_report();
LOG_INFO(*g_logger) << report << LOG_END;
LOG_FATAL(*g_logger) << report << LOG_END;
exit(static_cast<int>(JApplication::ExitCode::Segfault));
}

Expand Down Expand Up @@ -159,10 +159,10 @@ void register_handlers(JApplication* app) {
sigemptyset(&sSignalAction.sa_mask);
sigaction(SIGSEGV, &sSignalAction, nullptr);

LOG_INFO(*g_logger) << "Setting signal handler USR1. Use to write status info to the named pipe." << LOG_END;
LOG_WARN(*g_logger) << "Setting signal handler USR1. Use to write status info to the named pipe." << LOG_END;
signal(SIGUSR1, handle_usr1);
signal(SIGUSR2, handle_usr2);
LOG_INFO(*g_logger) << "Setting signal handler SIGINT (Ctrl-C). Use a single SIGINT to enter the Inspector, or multiple SIGINTs for an immediate shutdown." << LOG_END;
LOG_WARN(*g_logger) << "Setting signal handler SIGINT (Ctrl-C). Use a single SIGINT to enter the Inspector, or multiple SIGINTs for an immediate shutdown." << LOG_END;
signal(SIGINT, handle_sigint);
}

Expand Down
8 changes: 6 additions & 2 deletions src/libraries/JANA/Engine/JArrowProcessingController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Copyright 2020, Jefferson Science Associates, LLC.
// Subject to the terms in the LICENSE file found in the top-level directory.

#include "JANA/Services/JParameterManager.h"
#include <JANA/Engine/JArrowProcessingController.h>
#include <JANA/Engine/JPerfSummary.h>
#include <JANA/Services/JParameterManager.h>
#include <JANA/Topology/JTopologyBuilder.h>
#include <JANA/Utils/JCpuInfo.h>
#include <JANA/JLogger.h>
Expand Down Expand Up @@ -233,7 +233,11 @@ void JArrowProcessingController::print_report() {

void JArrowProcessingController::print_final_report() {
auto metrics = measure_performance();
LOG_INFO(GetLogger()) << "Final Report" << *metrics << LOG_END;


LOG_INFO(GetLogger()) << "Detailed report" << *metrics << LOG_END;
LOG_WARN(GetLogger()) << "Final report: " << metrics->total_events_completed << " events processed at "
<< JTypeInfo::to_string_with_si_prefix(metrics->avg_throughput_hz) << "Hz" << LOG_END;
}

std::unique_ptr<const JPerfSummary> JArrowProcessingController::measure_performance() {
Expand Down
36 changes: 17 additions & 19 deletions src/libraries/JANA/JApplication.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@
// Subject to the terms in the LICENSE file found in the top-level directory.

#include <JANA/JApplication.h>

#include <JANA/JEventSource.h>

#include <JANA/Utils/JCpuInfo.h>
#include <JANA/Services/JParameterManager.h>
#include <JANA/Engine/JArrowProcessingController.h>
#include <JANA/Services/JComponentManager.h>
#include <JANA/Services/JGlobalRootLock.h>
#include <JANA/Services/JParameterManager.h>
#include <JANA/Services/JPluginLoader.h>
#include <JANA/Services/JComponentManager.h>
#include <JANA/Services/JWiringService.h>
#include <JANA/Topology/JTopologyBuilder.h>
#include <JANA/Services/JGlobalRootLock.h>
#include <JANA/Engine/JArrowProcessingController.h>
#include <JANA/Services/JWiringService.h>
#include <JANA/Utils/JCpuInfo.h>
#include <JANA/Utils/JApplicationInspector.h>

#include <sstream>
Expand Down Expand Up @@ -108,17 +105,12 @@ void JApplication::Initialize() {
// Only run this once
if (m_initialized) return;

std::ostringstream oss;
oss << "Initializing..." << std::endl;
JVersion::PrintSplash(oss);
JVersion::PrintVersionDescription(oss);
LOG_INFO(m_logger) << oss.str() << LOG_END;

// Now that all parameters, components, plugin names, etc have been set,
// we can expose our builtin services to the user via GetService()
m_services_available = true;

// We trigger initialization
m_service_locator->get<JParameterManager>();
auto component_manager = m_service_locator->get<JComponentManager>();
auto plugin_loader = m_service_locator->get<JPluginLoader>();
auto topology_builder = m_service_locator->get<JTopologyBuilder>();
Expand All @@ -127,6 +119,12 @@ void JApplication::Initialize() {
m_logger = m_params->GetLogger("jana");
m_logger.show_classname = false;

std::ostringstream oss;
oss << "Initializing..." << std::endl;
JVersion::PrintSplash(oss);
JVersion::PrintVersionDescription(oss);
LOG_WARN(m_logger) << oss.str() << LOG_END;

// Set up wiring
ProvideService(std::make_shared<jana::services::JWiringService>());

Expand Down Expand Up @@ -191,7 +189,7 @@ void JApplication::Run(bool wait_until_finished) {
m_params->PrintParameters();

LOG_INFO(m_logger) << GetComponentSummary() << LOG_END;
LOG_INFO(m_logger) << "Starting processing with " << m_desired_nthreads << " threads requested..." << LOG_END;
LOG_WARN(m_logger) << "Starting processing with " << m_desired_nthreads << " threads requested..." << LOG_END;
m_processing_controller->run(m_desired_nthreads);

if (!wait_until_finished) {
Expand Down Expand Up @@ -258,7 +256,7 @@ void JApplication::Run(bool wait_until_finished) {
m_processing_controller->wait_until_stopped();
}

LOG_INFO(m_logger) << "Event processing ended." << LOG_END;
LOG_WARN(m_logger) << "Event processing ended." << LOG_END;
PrintFinalReport();

// Test for exception one more time, in case it shut down the topology before the supervisor could detect it
Expand All @@ -272,7 +270,7 @@ void JApplication::Run(bool wait_until_finished) {


void JApplication::Scale(int nthreads) {
LOG_INFO(m_logger) << "Scaling to " << nthreads << " threads" << LOG_END;
LOG_WARN(m_logger) << "Scaling to " << nthreads << " threads" << LOG_END;
m_processing_controller->scale(nthreads);
}

Expand Down Expand Up @@ -393,7 +391,7 @@ void JApplication::PrintStatus() {
else {
std::lock_guard<std::mutex> lock(m_status_mutex);
update_status();
LOG_INFO(m_logger) << "Status: " << m_perf_summary->total_events_completed << " events processed "
LOG_WARN(m_logger) << "Status: " << m_perf_summary->total_events_completed << " events processed at "
<< JTypeInfo::to_string_with_si_prefix(m_perf_summary->latest_throughput_hz) << "Hz ("
<< JTypeInfo::to_string_with_si_prefix(m_perf_summary->avg_throughput_hz) << "Hz avg)" << LOG_END;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/JANA/Services/JParameterManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void JParameterManager::PrintParameters(int verbosity, int strictness) {
}
}
if ((!param->IsDefault()) && (param->IsDeprecated())) {
LOG_WARN(m_logger) << "Parameter '" << key << "' has been deprecated and will no longer be supported in the next release." << LOG_END;
LOG_WARN(m_logger) << "Parameter '" << key << "' has been deprecated and may no longer be supported in future releases." << LOG_END;
warnings_present = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/JANA/Services/JPluginLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ void JPluginLoader::attach_plugin(std::string name, std::string path) {
}

// Run InitPlugin() and wrap exceptions as needed
LOG_INFO(m_logger) << "Initializing plugin \"" << name << "\" at path \"" << path << "\"" << LOG_END;
LOG_WARN(m_logger) << "Loading plugin '" << name << "' from '" << path << "'" << LOG_END;

try {
(*initialize_proc)(GetApplication());
Expand Down

0 comments on commit 5b6e9a5

Please sign in to comment.