|
Peano
|
Command Line Logger. More...
#include <ScorePLogger.h>

Public Member Functions | |
| ~ScorePLogger () | |
| bool | getLogMachineName () const |
| Is public as some analysis frameworks check explicitly whether these features are switched on. | |
| bool | getLogThreadName () const |
| Is public as some analysis frameworks check explicitly whether these features are switched on. | |
| bool | getLogTrace () const |
| Is public as some analysis frameworks check explicitly whether these features are switched on. | |
| bool | getLogTimeStamp () const |
| Is public as some analysis frameworks check explicitly whether these features are switched on. | |
| void | debug (long int timestampNanoseconds, int rank, int threadId, const std::string &trace, const std::string &message) |
| void | info (long int timestampNanoseconds, int rank, int threadId, const std::string &trace, const std::string &message) |
| void | warning (long int timestampNanoseconds, int rank, int threadId, const std::string &trace, const std::string &message) |
| Write Warning. | |
| void | error (long int timestampNanoseconds, int rank, int threadId, const std::string &trace, const std::string &message) |
| Write Error. | |
| void | traceIn (long int timestampNanoseconds, int rank, int threadId, const std::string &trace, const std::string &message) |
| void | traceOut (long int timestampNanoseconds, int rank, int threadId, const std::string &trace, const std::string &message) |
| Log trace out event. | |
| void | indent (bool indent, const std::string &trace) |
| Tells the logger to increment/decrement the indent. | |
| void | close () |
Static Public Member Functions | |
| static ScorePLogger & | getInstance () |
Private Member Functions | |
| ScorePLogger & | operator= (const CommandLineLogger &)=delete |
| Declared private since assignment does not make sense for an output class (output information mismatch). | |
| ScorePLogger (const ScorePLogger &)=delete | |
| Declared private since copying does not make sense for an output class (output information mismatch). | |
| std::string | constructMessageString (std::string messageType, long int timestampNanoseconds, int rank, int threadId, const std::string &trace, const std::string &message) |
| Construct message string. | |
| ScorePLogger () | |
| It's a singleton. | |
| std::string | getTimeStampHumanReadable (long int timestampNanoseconds) const |
Private Attributes | |
| tarch::multicore::MultiReadSingleWriteSemaphore | _semaphore |
Static Private Attributes | |
| static Log | _log |
| static ScorePLogger | _singleton |
Command Line Logger.
Log output device connecting to Score-P. Implements the LogHandle. Usually there's only one instance of this class for only the Log type aggregates it in a static way.
The logger accepts trace and log statements and forwards them to Score-P. Information messages, warning and errors are also piped onto the terminal. We follow the Score-P documentation from
https://www.vi-hps.org/projects/score-p/documentation/documentation.html
The idea is that the tracing holds one region handle per traced function. Per handle, we have to call
in line with https://perftools.pages.jsc.fz-juelich.de/cicd/scorep/tags/latest/html/group__SCOREP__User.html#ga8c8f772145f95dce57dcf86b6998365c. Obviously, define and init should be called only once, while we have an arbitrary number of enter-end calls.
The logger works with lazy generation of regions.
Obviously, we cannot use the define macro, as it creates a static instance and we work with lookup tables here instead of static attributes. Therefore, we do not work with the SCOREP_USER_REGION_DEFINE macro but instead directly with the underlying data type.
All of the Score-P labels here are logical. That is, they are tied to the logical function name and not the real one. In practice, this is not true, as Peano uses a lot of trace in and trace out macros to annotate specific regions. Anyway, we kind of replicate the Score-P instrumentation and both the instrumentation and the ScorePLogger can be used in tandem.
Definition at line 79 of file ScorePLogger.h.
|
privatedelete |
Declared private since copying does not make sense for an output class (output information mismatch).
|
private |
It's a singleton.
| tarch::logging::ScorePLogger::~ScorePLogger | ( | ) |
| void tarch::logging::ScorePLogger::close | ( | ) |
|
private |
Construct message string.
!!! Thread Safety
The message string relies on the global field _indent. This one might change throughout the execution of this method. However, I accept such a behavior: Changing _indent throughout the message execution makes the method add the wrong number of whitespaces in front of the message. That is a 'bug' we can accept.
To satisfy Intel Inspector et al at least slightly, I copy over _indent before I actually construct the message string. So the indent can't change while we add the spaces/tabs to the output.
| void tarch::logging::ScorePLogger::debug | ( | long int | timestampNanoseconds, |
| int | rank, | ||
| int | threadId, | ||
| const std::string & | trace, | ||
| const std::string & | message | ||
| ) |
| void tarch::logging::ScorePLogger::error | ( | long int | timestampNanoseconds, |
| int | rank, | ||
| int | threadId, | ||
| const std::string & | trace, | ||
| const std::string & | message | ||
| ) |
Write Error.
In the implementation, I call a flush on cout before I write to cerr. Otherwise, the cerr messages might overtake cout. Before the operation returns, it does a flush on cerr, too. Otherwise, the message might not occur, i.e. the application might shut down before the message is flushed to the terminal.
|
static |
| bool tarch::logging::ScorePLogger::getLogMachineName | ( | ) | const |
Is public as some analysis frameworks check explicitly whether these features are switched on.
| bool tarch::logging::ScorePLogger::getLogThreadName | ( | ) | const |
Is public as some analysis frameworks check explicitly whether these features are switched on.
| bool tarch::logging::ScorePLogger::getLogTimeStamp | ( | ) | const |
Is public as some analysis frameworks check explicitly whether these features are switched on.
| bool tarch::logging::ScorePLogger::getLogTrace | ( | ) | const |
Is public as some analysis frameworks check explicitly whether these features are switched on.
|
private |
| void tarch::logging::ScorePLogger::indent | ( | bool | indent, |
| const std::string & | trace | ||
| ) |
Tells the logger to increment/decrement the indent.
For Score-P, we do not need any indentation. Consequently, we put the nop implementation into the header, so the compiler can inline the call and eventually remove it completely.
Definition at line 212 of file ScorePLogger.h.
| void tarch::logging::ScorePLogger::info | ( | long int | timestampNanoseconds, |
| int | rank, | ||
| int | threadId, | ||
| const std::string & | trace, | ||
| const std::string & | message | ||
| ) |
|
privatedelete |
Declared private since assignment does not make sense for an output class (output information mismatch).
| void tarch::logging::ScorePLogger::traceIn | ( | long int | timestampNanoseconds, |
| int | rank, | ||
| int | threadId, | ||
| const std::string & | trace, | ||
| const std::string & | message | ||
| ) |
| void tarch::logging::ScorePLogger::traceOut | ( | long int | timestampNanoseconds, |
| int | rank, | ||
| int | threadId, | ||
| const std::string & | trace, | ||
| const std::string & | message | ||
| ) |
Log trace out event.
This event forwards the call to a call of the
macro. In earlier versions, it used to delegate to
but that macro seems to be discontinued in Score-P 6.
| void tarch::logging::ScorePLogger::warning | ( | long int | timestampNanoseconds, |
| int | rank, | ||
| int | threadId, | ||
| const std::string & | trace, | ||
| const std::string & | message | ||
| ) |
Write Warning.
In the implementation, I call a flush on cout before I write to cerr. Otherwise, the cerr messages might overtake cout. Before the operation returns, it does a flush on cerr, too. Otherwise, the message might not occur, i.e. the application might shut down before the message is flushed to the terminal.
|
staticprivate |
Definition at line 81 of file ScorePLogger.h.
|
private |
Definition at line 85 of file ScorePLogger.h.
|
staticprivate |
Definition at line 83 of file ScorePLogger.h.