Peano
Loading...
Searching...
No Matches
CommandLineLogger.h
Go to the documentation of this file.
1// This file is part of the Peano project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#pragma once
4
5#ifdef Parallel
6#include <mpi.h>
7#endif
8
9#include <iostream>
10#include <fstream>
11#include <set>
12#include <stack>
13
16#include "tarch/logging/Log.h"
17
18namespace tarch {
19 namespace logging {
20 class CommandLineLogger;
21 }
22}
23
49 private:
50 static Log _log;
51
53
55
66 std::ostream* _outputStream;
69 std::string _outputFileName;
71
77
83
87 static std::string::size_type _indent;
88
92 static const std::string::size_type NumberOfIndentSpaces;
93
97 static const std::string::size_type NumberOfStandardColumnSpaces;
98
106 static const std::string::size_type NumberOfTraceColumnSpaces;
107
109
115 std::string addSeparators(std::string::size_type spaces, std::string message) const;
116
132 std::string constructMessageString(
133 std::string messageType,
134 long int timestampNanoseconds, int rank, int threadId, const std::string& trace, const std::string& message
135 );
136
140 static std::string getTimeStampHumanReadable( long int timestampNanoseconds );
141
146
151
152 std::string getLogColumnSeparator() const;
153 bool getLogTimeStampHumanReadable() const;
154 bool getLogMessageType() const;
155
156 std::ostream& out();
157
158 void reopenOutputStream();
159
160 std::stack< std::string > _indentTraces;
161
162 public:
164
166
171 bool getLogMachineName() const;
172
177 bool getLogThreadName() const;
178
183 bool getLogTrace() const;
184
189 bool getLogTimeStamp() const;
190
191 void debug( long int timestampNanoseconds, int rank, int threadId, const std::string& trace, const std::string& message);
192 void info( long int timestampNanoseconds, int rank, int threadId, const std::string& trace, const std::string& message);
193
203 void warning( long int timestampNanoseconds, int rank, int threadId, const std::string& trace, const std::string& message);
204
214 void error( long int timestampNanoseconds, int rank, int threadId, const std::string& trace, const std::string& message);
215
216 void traceIn( long int timestampNanoseconds, int rank, int threadId, const std::string& trace, const std::string& message);
217 void traceOut( long int timestampNanoseconds, int rank, int threadId, const std::string& trace, const std::string& message);
218
245 void indent( bool indent, const std::string& trace, const std::string& message );
246
247 void setLogColumnSeparator( const std::string& separator = " ");
248 void setLogTimeStamp( bool value = true );
249 void setLogTimeStampHumanReadable( bool value = true );
250 void setLogMachineName( bool value = true );
251 void setLogThreadName( bool value = true );
252 void setLogMessageType( bool value = true );
253 void setLogTrace( bool value = true );
254
262 void setLogFormat(
263 const std::string& columnSeparator,
264 bool logTimeStamp,
265 bool logTimeStampHumanReadable,
266 bool logMachineName,
267 bool logThreadName,
268 bool logMessageType,
269 bool logTrace,
270 const std::string& outputLogFileName
271 );
272
278 void setOutputFile( const std::string& outputLogFileName );
279
280 void setQuitOnError(bool value);
281
296
297 void close();
298};
std::string _logColumnSeparator
Test for the column separator of a string output.
std::stack< std::string > _indentTraces
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.
static const std::string::size_type NumberOfIndentSpaces
std::string constructMessageString(std::string messageType, long int timestampNanoseconds, int rank, int threadId, const std::string &trace, const std::string &message)
Construct message string.
void closeOutputStreamAndReopenNewOne()
The command line logger can pipe debug data into an output file instead of piping everything to the t...
tarch::multicore::BooleanSemaphore _semaphore
static const std::string::size_type NumberOfStandardColumnSpaces
void setLogTimeStampHumanReadable(bool value=true)
void setLogFormat(const std::string &columnSeparator, bool logTimeStamp, bool logTimeStampHumanReadable, bool logMachineName, bool logThreadName, bool logMessageType, bool logTrace, const std::string &outputLogFileName)
void setLogColumnSeparator(const std::string &separator=" ")
static CommandLineLogger & getInstance()
void indent(bool indent, const std::string &trace, const std::string &message)
Tells the logger to increment/decrement the indent.
static std::string getTimeStampHumanReadable(long int timestampNanoseconds)
static const std::string::size_type NumberOfTraceColumnSpaces
The trace column is not formatted using only tabulators, but it uses spaces to create a unique column...
void traceOut(long int timestampNanoseconds, int rank, int threadId, const std::string &trace, const std::string &message)
void configureOutputStreams()
Configures the output streams.
static CommandLineLogger _singleton
CommandLineLogger & operator=(const CommandLineLogger &)
Declared private since assignment does not make sense for an output class (output information mismatc...
void debug(long int timestampNanoseconds, int rank, int threadId, const std::string &trace, const std::string &message)
void error(long int timestampNanoseconds, int rank, int threadId, const std::string &trace, const std::string &message)
Write Error.
bool getLogMachineName() const
Is public as some analysis frameworks check explicitly whether these features are switched on.
void setOutputFile(const std::string &outputLogFileName)
Is redundant, as you could use setLogFormat() instead.
void traceIn(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)
static std::string::size_type _indent
Indent is supported only in debug mode.
std::string addSeparators(std::string::size_type spaces, std::string message) const
Takes the message and adds spaces such that the entries are aligned like in a table.
void warning(long int timestampNanoseconds, int rank, int threadId, const std::string &trace, const std::string &message)
Write Warning.
bool getLogThreadName() const
Is public as some analysis frameworks check explicitly whether these features are switched on.
Log Device.
Definition Log.h:516
Have to include this header, as I need access to the SYCL_EXTERNAL keyword.
Definition accelerator.h:19