Base class for output of errors, messages, warnings, etc.

(logging class). Must be specialized for specific output, for example output to console, to windows, etc. by inheriting custom classes. See below, an example for logging to std::cout

#include <ChLog.h>

Inheritance diagram for chrono::ChLog:
Collaboration diagram for chrono::ChLog:

Public Types

enum  eChLogLevel {
 There are different levels of log messages. More...
- Public Types inherited from chrono::ChStream
 [Obsolete] Modes for chrono files (the ch-modes). More...
 Errors for chrono files (the ch-modes). More...

Public Member Functions

virtual void Flush ()
 Forces output of message buffers, if any. More...
void SetDefaultLevel (eChLogLevel mlev)
 Sets the default level, to be used from now on.
void SetCurrentLevel (eChLogLevel mlev)
 Sets the current level, to be used until new flushing.
eChLogLevel GetCurrentLevel ()
 Gets the current level.
void RestoreDefaultLevel ()
 Restore the default level.
ChLogoperator- (eChLogLevel mnewlev)
 Using the - operator is easy to set the status of the log, so in you code you can write, for example: GetLog() - ChLog::CHERROR << "a big error in " << mynumber << " items \n" ;.
- Public Member Functions inherited from chrono::ChStreamOutAscii
ChStreamOutAsciioperator<< (bool bVal)
 Generic << operator for all classes which implement serialization by means of a method named 'void StreamOut(ChStreamOutAscii&)'.
ChStreamOutAsciioperator<< (char tch)
ChStreamOutAsciioperator<< (const int nVal)
ChStreamOutAsciioperator<< (const double dVal)
ChStreamOutAsciioperator<< (const float fVal)
ChStreamOutAsciioperator<< (unsigned int unVal)
ChStreamOutAsciioperator<< (char *str)
ChStreamOutAsciioperator<< (const char *str)
ChStreamOutAsciioperator<< (const std::string &str)
ChStreamOutAsciioperator<< (unsigned long unVal)
ChStreamOutAsciioperator<< (unsigned long long unVal)
template<class T >
ChStreamOutAsciioperator< (T obj)
 OBSOLETE use ChArchive << operator and ArchiveOut()
virtual void Format (char *formatString,...)
 Output the log message in form of a formatted string, like in printf().
void SetNumFormat (const char *mf)
 Set the formatting string (ex "%f" or "%g" etc.) for float->text conversion.
char * GetNumFormat ()
void SetCommentTrailer (char *mt)
 Set the trailer symbol before each comment (example: "#" , or "//").
void CR ()
 Outputs carriage return.
void TAB ()
 Output tab.
void Comment (char m_string[])
 Output comment with preceding trailer (e.g., #).
void Bar ()
 Output a separation bar in ASCII file.

Protected Member Functions

 ChLog ()
 Creates the ChLog, and sets the level at MESSAGE.
- Protected Member Functions inherited from chrono::ChStreamOut
virtual void Output (const char *data, size_t n)=0
 Outputs a raw chunk of data, from pointer 'data' up to 'n' chars (bytes). More...

Protected Attributes

eChLogLevel current_level
eChLogLevel default_level
- Protected Attributes inherited from chrono::ChStreamOutAscii
char number_format [10]
char comment_trailer [10]

Member Enumeration Documentation

◆ eChLogLevel

There are different levels of log messages.

This is indifferent for the base class, but more sophisticated specializations of the ChLog class may handle message output in different ways (for example a ChLogForGUIapplication may print logs in STATUS level only to the bottom of the window, etc.)

Member Function Documentation

◆ Flush()

virtual void chrono::ChLog::Flush ( )

Forces output of message buffers, if any.

Also, should restore the default eChLogLevel This base class does pretty nothing, but inherited classes should override this method with more specific implementations.

The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono/core/ChLog.h
  • /builds/uwsbel/chrono/src/chrono/core/ChLog.cpp