Skip to content

Commit adad922

Browse files
committed
Merge pull request #144 from torbjoernk/feature/logging
logging improvements
2 parents d7fe9ac + 8bb7b3f commit adad922

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

include/pfasst/logging.hpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const string OUT::reset = "\033[0m";
5757

5858
#include <pfasst/easylogging++.h>
5959

60+
6061
#ifndef PFASST_LOGGER_INITIALIZED
6162
// initialize easyloggingpp
6263
// FIXME: this might already be called by code using PFASST++
@@ -78,11 +79,31 @@ const string OUT::reset = "\033[0m";
7879
#define PFASST_LOGGER_DEFAULT_GLOBAL_MILLISECOND_WIDTH "4"
7980
#endif
8081

82+
#ifndef VLOG_FUNC_START
83+
#define VLOG_FUNC_START(scope) \
84+
pfasst::log::stack_position++; \
85+
VLOG(9) << std::string((pfasst::log::stack_position - 1) * 2, ' ') << "START:" << std::string(scope) + "::" + std::string(__func__) + "() "
86+
#endif
87+
88+
#ifndef VLOG_FUNC_END
89+
#define VLOG_FUNC_END(scope) \
90+
pfasst::log::stack_position--; \
91+
VLOG(9) << std::string(pfasst::log::stack_position * 2, ' ') << "DONE: " << std::string(scope) + "::" + std::string(__func__) + "()";
92+
#endif
93+
94+
#ifndef LOG_PRECISION
95+
#define LOG_PRECISION 5
96+
#endif
97+
98+
#define LOG_INDENT string(pfasst::log::stack_position * 2, ' ')
99+
81100

82101
namespace pfasst
83102
{
84103
namespace log
85104
{
105+
static size_t stack_position;
106+
86107
/**
87108
* sets default configuration for default loggers
88109
*/
@@ -139,7 +160,7 @@ namespace pfasst
139160
*/
140161
inline static void set_logging_flags()
141162
{
142-
el::Loggers::addFlag(el::LoggingFlag::NewLineForContainer);
163+
// el::Loggers::addFlag(el::LoggingFlag::NewLineForContainer);
143164
el::Loggers::addFlag(el::LoggingFlag::LogDetailedCrashReason);
144165
el::Loggers::addFlag(el::LoggingFlag::DisableApplicationAbortOnFatalLog);
145166
el::Loggers::addFlag(el::LoggingFlag::ColoredTerminalOutput);
@@ -181,6 +202,7 @@ namespace pfasst
181202
_START_EASYLOGGINGPP(argc, argv);
182203
set_logging_flags();
183204
load_default_config();
205+
pfasst::log::stack_position = 0;
184206
}
185207
} // ::pfasst::log
186208
} // ::pfasst

0 commit comments

Comments
 (0)