Skip to content

Commit

Permalink
Fixed Issue #104 by improving WRENCH_* logging macros
Browse files Browse the repository at this point in the history
  • Loading branch information
henricasanova committed Jun 19, 2019
1 parent 1e0584a commit f745b52
Show file tree
Hide file tree
Showing 52 changed files with 87 additions and 71 deletions.
32 changes: 26 additions & 6 deletions include/wrench/logging/TerminalOutput.h
Expand Up @@ -13,19 +13,39 @@
#include <map>

#include <simgrid/s4u/Actor.hpp>
#include <xbt/log.h>

#include <iostream>

namespace wrench {


/* Wrappers around XBT_* macros */

#define WRENCH_INFO(...) wrench::TerminalOutput::beginThisProcessColor(); XBT_INFO(__VA_ARGS__) ; wrench::TerminalOutput::endThisProcessColor()

#define WRENCH_DEBUG(...) wrench::TerminalOutput::beginThisProcessColor(); XBT_DEBUG(__VA_ARGS__) ; wrench::TerminalOutput::endThisProcessColor()
/* Wrappers around XBT_* macros, using a bit of those macro's internal magic as well
* to avoid generating useless (but space consuming) color ASCII codes
*/

#define WRENCH_WARN(...) wrench::TerminalOutput::beginThisProcessColor(); XBT_WARN(__VA_ARGS__) ; wrench::TerminalOutput::endThisProcessColor()
#define WRENCH_LOG_NEW_DEFAULT_CATEGORY(cname, desc) XBT_LOG_NEW_DEFAULT_CATEGORY(cname, desc)

#define WRENCH_INFO(...) \
if (_XBT_LOG_ISENABLEDV((*_simgrid_log_category__default), xbt_log_priority_info)) { \
wrench::TerminalOutput::beginThisProcessColor(); \
XBT_INFO(__VA_ARGS__) ; \
wrench::TerminalOutput::endThisProcessColor(); \
}

#define WRENCH_DEBUG(...) \
if (_XBT_LOG_ISENABLEDV((*_simgrid_log_category__default), xbt_log_priority_debug)) { \
wrench::TerminalOutput::beginThisProcessColor(); \
XBT_DEBUG(__VA_ARGS__) ; \
wrench::TerminalOutput::endThisProcessColor(); \
}

#define WRENCH_WARN(...) \
if (_XBT_LOG_ISENABLEDV((*_simgrid_log_category__default), xbt_log_priority_warning)) { \
wrench::TerminalOutput::beginThisProcessColor(); \
XBT_WARN(__VA_ARGS__) ; \
wrench::TerminalOutput::endThisProcessColor(); \
}

/***********************/
/** \cond DEVELOPER */
Expand Down
5 changes: 2 additions & 3 deletions src/wrench/logging/TerminalOutput.cpp
Expand Up @@ -10,7 +10,6 @@
#include <string>
#include <simgrid/s4u/Actor.hpp>
#include <iostream>
#include <xbt/log.h>
#include "wrench/logging/TerminalOutput.h"

namespace wrench {
Expand Down Expand Up @@ -44,7 +43,7 @@ namespace wrench {
*/
void TerminalOutput::beginThisProcessColor() {

if ((not TerminalOutput::wrench_no_log) and (TerminalOutput::color_enabled)) {
if (TerminalOutput::color_enabled) {
std::cerr << TerminalOutput::getThisProcessLoggingColor();
}
}
Expand All @@ -53,7 +52,7 @@ namespace wrench {
* @brief Turn off colored output for the calling process
*/
void TerminalOutput::endThisProcessColor() {
if ((not TerminalOutput::wrench_no_log) and (TerminalOutput::color_enabled)) {
if (TerminalOutput::color_enabled) {
std::cerr << "\033[0m";
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/wrench/managers/DataMovementManager.cpp
Expand Up @@ -23,7 +23,7 @@
#include "wrench/workflow/Workflow.h"
#include "wrench/managers/DataMovementManager.h"

XBT_LOG_NEW_DEFAULT_CATEGORY(data_movement_manager, "Log category for Data Movement Manager");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(data_movement_manager, "Log category for Data Movement Manager");

namespace wrench {

Expand Down
2 changes: 1 addition & 1 deletion src/wrench/managers/EnergyMeter.cpp
Expand Up @@ -14,7 +14,7 @@

#define EPSILON 0.0001

XBT_LOG_NEW_DEFAULT_CATEGORY(energy_meter, "Log category for Energy Meter");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(energy_meter, "Log category for Energy Meter");

namespace wrench {

Expand Down
2 changes: 1 addition & 1 deletion src/wrench/managers/JobManager.cpp
Expand Up @@ -26,7 +26,7 @@
#include "JobManagerMessage.h"


XBT_LOG_NEW_DEFAULT_CATEGORY(job_manager, "Log category for Job Manager");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(job_manager, "Log category for Job Manager");

namespace wrench {

Expand Down
2 changes: 1 addition & 1 deletion src/wrench/services/Service.cpp
Expand Up @@ -17,7 +17,7 @@
#include "wrench/exceptions/WorkflowExecutionException.h"
#include "wrench/services/ServiceMessagePayload.h"

XBT_LOG_NEW_DEFAULT_CATEGORY(service, "Log category for Service");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(service, "Log category for Service");


namespace wrench {
Expand Down
2 changes: 1 addition & 1 deletion src/wrench/services/compute/ComputeService.cpp
Expand Up @@ -17,7 +17,7 @@
#include "wrench/services/compute/ComputeServiceMessage.h"
#include "wrench/simgrid_S4U_util/S4U_Mailbox.h"

XBT_LOG_NEW_DEFAULT_CATEGORY(compute_service, "Log category for Compute Service");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(compute_service, "Log category for Compute Service");

namespace wrench {

Expand Down
Expand Up @@ -34,7 +34,7 @@
#include "wrench/services/helpers/ServiceTerminationDetector.h"
#include "wrench/services/helpers/HostStateChangeDetector.h"

XBT_LOG_NEW_DEFAULT_CATEGORY(baremetal_compute_service, "Log category for BareMetalComputeService");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(baremetal_compute_service, "Log category for BareMetalComputeService");

namespace wrench {

Expand Down
2 changes: 1 addition & 1 deletion src/wrench/services/compute/batch/BatchComputeService.cpp
Expand Up @@ -39,7 +39,7 @@

#endif

XBT_LOG_NEW_DEFAULT_CATEGORY(batch_service, "Log category for Batch Service");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(batch_service, "Log category for Batch Service");

namespace wrench {

Expand Down
Expand Up @@ -27,7 +27,7 @@

#endif

XBT_LOG_NEW_DEFAULT_CATEGORY(batch_network_listener_service, "Log category for Batch Network Listener Service");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(batch_network_listener_service, "Log category for Batch Network Listener Service");

//class context_t;

Expand Down
4 changes: 2 additions & 2 deletions src/wrench/services/compute/batch/TraceFileLoader.cpp
Expand Up @@ -8,12 +8,12 @@
*/

#include <fstream>
#include <xbt/log.h>
#include "wrench/logging/TerminalOutput.h"
#include <wrench-dev.h>
#include <nlohmann/json.hpp>
#include "wrench/util/TraceFileLoader.h"

XBT_LOG_NEW_DEFAULT_CATEGORY(trace_file_loader, "Log category for Trace File Loader");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(trace_file_loader, "Log category for Trace File Loader");

namespace wrench {

Expand Down
Expand Up @@ -14,7 +14,7 @@
#include "WorkloadTraceFileReplayer.h"
#include "WorkloadTraceFileReplayerEventReceiver.h"

XBT_LOG_NEW_DEFAULT_CATEGORY(workload_trace_file_replayer, "Log category for Trace File Replayer");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(workload_trace_file_replayer, "Log category for Trace File Replayer");

namespace wrench {

Expand Down
Expand Up @@ -12,7 +12,7 @@
#include <wrench-dev.h>
#include "WorkloadTraceFileReplayerEventReceiver.h"

XBT_LOG_NEW_DEFAULT_CATEGORY(one_job_wms, "Log category for One Job WMS");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(one_job_wms, "Log category for One Job WMS");

namespace wrench {

Expand Down
2 changes: 1 addition & 1 deletion src/wrench/services/compute/cloud/CloudComputeService.cpp
Expand Up @@ -21,7 +21,7 @@
#include "wrench/simgrid_S4U_util/S4U_Mailbox.h"


XBT_LOG_NEW_DEFAULT_CATEGORY(cloud_service, "Log category for Cloud Service");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(cloud_service, "Log category for Cloud Service");

namespace wrench {

Expand Down
Expand Up @@ -18,7 +18,7 @@
#include "wrench/services/compute/htcondor/HTCondorNegotiatorService.h"
#include "wrench/simgrid_S4U_util/S4U_Mailbox.h"

XBT_LOG_NEW_DEFAULT_CATEGORY(HTCondorCentralManager, "Log category for HTCondorCentralManagerService");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(HTCondorCentralManager, "Log category for HTCondorCentralManagerService");

namespace wrench {

Expand Down
Expand Up @@ -15,7 +15,7 @@
#include "wrench/simgrid_S4U_util/S4U_Simulation.h"
#include "wrench/workflow/WorkflowTask.h"

XBT_LOG_NEW_DEFAULT_CATEGORY(htcondor_negotiator, "Log category for HTCondorNegotiator");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(htcondor_negotiator, "Log category for HTCondorNegotiator");

namespace wrench {

Expand Down
2 changes: 1 addition & 1 deletion src/wrench/services/compute/htcondor/HTCondorService.cpp
Expand Up @@ -13,7 +13,7 @@
#include "wrench/simgrid_S4U_util/S4U_Mailbox.h"
#include "wrench/simgrid_S4U_util/S4U_Simulation.h"

XBT_LOG_NEW_DEFAULT_CATEGORY(HTCondor, "Log category for HTCondorService Scheduler");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(HTCondor, "Log category for HTCondorService Scheduler");

namespace wrench {

Expand Down
Expand Up @@ -33,7 +33,7 @@

#include "wrench/util/PointerUtil.h"

XBT_LOG_NEW_DEFAULT_CATEGORY(standard_job_executor, "Log category for Standard Job Executor");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(standard_job_executor, "Log category for Standard Job Executor");

namespace wrench {

Expand Down
Expand Up @@ -20,7 +20,7 @@
#include "wrench/simgrid_S4U_util/S4U_Mailbox.h"


XBT_LOG_NEW_DEFAULT_CATEGORY(virtualized_cluster_service, "Log category for Virtualized Cluster Service");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(virtualized_cluster_service, "Log category for Virtualized Cluster Service");

namespace wrench {

Expand Down
Expand Up @@ -8,13 +8,11 @@
* (at your option) any later version.
*/

#include <xbt.h>
#include "wrench/logging/TerminalOutput.h"
#include <wrench-dev.h>
#include "ComputeThread.h"


XBT_LOG_NEW_DEFAULT_CATEGORY(compute_thread, "Log category for ComputeThread");

WRENCH_LOG_NEW_DEFAULT_CATEGORY(compute_thread, "Log category for ComputeThread");

namespace wrench {

Expand Down
Expand Up @@ -14,7 +14,7 @@
#include "wrench/services/compute/workunit_executor/Workunit.h"
#include <wrench-dev.h>

XBT_LOG_NEW_DEFAULT_CATEGORY(workunit, "Log category for Workunit");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(workunit, "Log category for Workunit");


namespace wrench {
Expand Down
Expand Up @@ -26,11 +26,11 @@
#include "ComputeThread.h"
#include "wrench/simulation/Simulation.h"

#include <xbt.h>
#include "wrench/logging/TerminalOutput.h"
#include <wrench/services/compute/ComputeService.h>


XBT_LOG_NEW_DEFAULT_CATEGORY(workunit_executor, "Log category for Multicore Workunit Executor");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(workunit_executor, "Log category for Multicore Workunit Executor");

//#define S4U_KILL_JOIN_WORKS

Expand Down
2 changes: 1 addition & 1 deletion src/wrench/services/file_registry/FileRegistryService.cpp
Expand Up @@ -22,7 +22,7 @@
#include <wrench/services/network_proximity/NetworkProximityService.h>
#include <algorithm>

XBT_LOG_NEW_DEFAULT_CATEGORY(file_registry_service, "Log category for File Registry Service");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(file_registry_service, "Log category for File Registry Service");

namespace wrench {

Expand Down
2 changes: 1 addition & 1 deletion src/wrench/services/helpers/alarm/Alarm.cpp
Expand Up @@ -14,7 +14,7 @@
#include "wrench/simgrid_S4U_util/S4U_Simulation.h"
#include "wrench/workflow/execution_events/FailureCause.h"

XBT_LOG_NEW_DEFAULT_CATEGORY(alarm_service, "Log category for Alarm Service");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(alarm_service, "Log category for Alarm Service");

namespace wrench {

Expand Down
Expand Up @@ -16,7 +16,7 @@
#include <wrench/services/helpers/HostStateChangeDetector.h>


XBT_LOG_NEW_DEFAULT_CATEGORY(host_state_change_detector, "Log category for HostStateChangeDetector");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(host_state_change_detector, "Log category for HostStateChangeDetector");


void wrench::HostStateChangeDetector::cleanup(bool has_returned_from_main, int return_value) {
Expand Down
Expand Up @@ -13,7 +13,7 @@
#include <wrench/simulation/Simulation.h>
#include <wrench-dev.h>

XBT_LOG_NEW_DEFAULT_CATEGORY(failure_detector, "Log category for ServiceTerminationDetector");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(failure_detector, "Log category for ServiceTerminationDetector");

/**
* @brief Constructor
Expand Down
Expand Up @@ -18,7 +18,7 @@
#include "NetworkProximityMessage.h"


XBT_LOG_NEW_DEFAULT_CATEGORY(network_daemons_service, "Log category for Network Daemons Service");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(network_daemons_service, "Log category for Network Daemons Service");

namespace wrench {

Expand Down
Expand Up @@ -24,7 +24,7 @@

#include <boost/algorithm/string.hpp>

XBT_LOG_NEW_DEFAULT_CATEGORY(network_proximity_service, "Log category for Network Proximity Service");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(network_proximity_service, "Log category for Network Proximity Service");

namespace wrench {

Expand Down
2 changes: 1 addition & 1 deletion src/wrench/services/storage/StorageService.cpp
Expand Up @@ -17,7 +17,7 @@
#include "wrench/simgrid_S4U_util/S4U_Mailbox.h"
#include "wrench/simulation/Simulation.h"

XBT_LOG_NEW_DEFAULT_CATEGORY(storage_service, "Log category for Storage Service");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(storage_service, "Log category for Storage Service");


namespace wrench {
Expand Down
2 changes: 1 addition & 1 deletion src/wrench/services/storage/simple/NetworkConnection.cpp
Expand Up @@ -16,7 +16,7 @@
//#include <xbt/ex.hpp>


XBT_LOG_NEW_DEFAULT_CATEGORY(simple_storage_service_data_connection, "Log category for Data Connection");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(simple_storage_service_data_connection, "Log category for Data Connection");

namespace wrench {

Expand Down
Expand Up @@ -11,7 +11,7 @@
#include <wrench/simgrid_S4U_util/S4U_PendingCommunication.h>
#include <wrench-dev.h>

XBT_LOG_NEW_DEFAULT_CATEGORY(network_connection_manager, "Log category for Network Connection Manager");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(network_connection_manager, "Log category for Network Connection Manager");


namespace wrench {
Expand Down
Expand Up @@ -21,7 +21,7 @@
#include "wrench/simulation/SimulationTimestampTypes.h"


XBT_LOG_NEW_DEFAULT_CATEGORY(simple_storage_service, "Log category for Simple Storage Service");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(simple_storage_service, "Log category for Simple Storage Service");


namespace wrench {
Expand Down
2 changes: 1 addition & 1 deletion src/wrench/simgrid_S4U_util/S4U_Daemon.cpp
Expand Up @@ -19,7 +19,7 @@
#endif


XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_daemon, "Log category for S4U_Daemon");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(s4u_daemon, "Log category for S4U_Daemon");

#ifdef ACTOR_TRACKING_OUTPUT
std::map<std::string, unsigned long> num_actors;
Expand Down
4 changes: 2 additions & 2 deletions src/wrench/simgrid_S4U_util/S4U_DaemonActor.cpp
Expand Up @@ -9,9 +9,9 @@
*
*/

#include <xbt/log.h>
#include "wrench/logging/TerminalOutput.h"

XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_daemon_actor, "Log category for S4U_DaemonActor");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(s4u_daemon_actor, "Log category for S4U_DaemonActor");

namespace wrench {

Expand Down
2 changes: 1 addition & 1 deletion src/wrench/simgrid_S4U_util/S4U_DaemonActor.h
Expand Up @@ -13,7 +13,7 @@
#define WRENCH_SIM4U_DAEMONACTOR_H


#include <xbt.h>
#include "wrench/logging/TerminalOutput.h"
#include <string>
#include <vector>
#include <iostream>
Expand Down
2 changes: 1 addition & 1 deletion src/wrench/simgrid_S4U_util/S4U_Mailbox.cpp
Expand Up @@ -24,7 +24,7 @@
#include "wrench/simgrid_S4U_util/S4U_PendingCommunication.h"
#include "wrench/simulation/SimulationMessage.h"

XBT_LOG_NEW_DEFAULT_CATEGORY(mailbox, "Mailbox");
WRENCH_LOG_NEW_DEFAULT_CATEGORY(mailbox, "Mailbox");


namespace wrench {
Expand Down

0 comments on commit f745b52

Please sign in to comment.