|
AGXDynamics
2.31.1.0
|
Class for printing out messages to console, file, virtual method and or a callback function. More...
#include <LogStream.h>
Inheritance diagram for agx::LogStream:Public Types | |
| typedef void(* | CallbackFunction_t )(const char *, unsigned int) |
| enum | OutputMode { CERR = 1, COUT = 2, FILE = 4, FUNCTION = 8 } |
| Enums used to specify the output mode used. These can be OR:ed together. More... | |
Public Member Functions | |
| LogStream () | |
| Constructor. More... | |
| virtual | ~LogStream () |
| Flush and empty all buffers, and then remove the allocated buffers. More... | |
| void | appendOutputMode (short modemask) |
| OR:s together the active outputmode with modemask. More... | |
| void | clearOutputMode (void) |
| Resets the active output modes to none. More... | |
| void | close (void) |
| void | flush () |
| CallbackFunction_t | getCallback () |
| const agx::String & | getDateFormat () const |
| bool | getEnableDate () const |
| bool | getEnableThreadId () const |
| agx::String | getFilename () const |
| int | getOutputMode (void) |
| Returns the active outputmode. More... | |
| bool | haveOpenFile () const |
| bool | isActive (OutputMode modemask) |
| Returns true if the modemask is set as the active output mode. More... | |
| virtual void | message (const char *msg, unsigned int length) |
| This method will be called whenever there is a message ready for output. More... | |
| bool | open (const agx::String &name) |
| Open a specified file as a log. More... | |
| void | setCallback (CallbackFunction_t f) |
| Sets the function that will be called if FUNCTION is set as outputmode. More... | |
| void | setDateFormat (const agx::String &date_format) |
| Specify the format of the date/time string that getTimeString() will return Look at strftime for examples of how to specify the date. More... | |
| void | setEnableDate (bool flag) |
If flag == true, the date in the specified date format will be added prior to each message. More... | |
| void | setEnableThreadId (bool flag) |
| If set to true, the messages will be prefixed with the id of the thread that generates the message. More... | |
| void | setOutputMode (short modemask) |
| Set the active outputmode to modemask. More... | |
Static Public Member Functions | |
| static agx::String | getTimeString (const agx::String &dateFormat="", bool logTimeWithMilliseconds=true) |
Protected Member Functions | |
| LogStream (const LogStream &) | |
| LogStream & | operator= (const LogStream &) |
| size_t | write (const char *msg, std::streamsize count) |
Protected Attributes | |
| CallbackFunction_t | m_callback |
| ::FILE * | m_file |
| agx::String | m_filename |
| bool | m_isOpen |
| int | m_mode |
Class for printing out messages to console, file, virtual method and or a callback function.
Definition at line 44 of file LogStream.h.
| typedef void( * agx::LogStream::CallbackFunction_t)(const char *, unsigned int) |
Definition at line 53 of file LogStream.h.
Enums used to specify the output mode used. These can be OR:ed together.
| Enumerator | |
|---|---|
| CERR | |
| COUT | |
| FILE | |
| FUNCTION | |
Definition at line 85 of file LogStream.h.
| agx::LogStream::LogStream | ( | ) |
Constructor.
|
virtual |
Flush and empty all buffers, and then remove the allocated buffers.
|
protected |
| void agx::LogStream::appendOutputMode | ( | short | modemask | ) |
OR:s together the active outputmode with modemask.
| void agx::LogStream::flush | ( | ) |
| CallbackFunction_t agx::LogStream::getCallback | ( | ) |
| const agx::String& agx::LogStream::getDateFormat | ( | ) | const |
| bool agx::LogStream::getEnableDate | ( | ) | const |
| bool agx::LogStream::getEnableThreadId | ( | ) | const |
| agx::String agx::LogStream::getFilename | ( | ) | const |
| int agx::LogStream::getOutputMode | ( | void | ) |
Returns the active outputmode.
|
static |
| dateFormat | - Format in date (if logTimeWithMilliseconds==false) as being used by the method strftime() |
| logTimeWithMilliseconds | - If true (default) the date string will be reported in milliseconds |
| bool agx::LogStream::haveOpenFile | ( | ) | const |
| bool agx::LogStream::isActive | ( | OutputMode | modemask | ) |
Returns true if the modemask is set as the active output mode.
|
virtual |
This method will be called whenever there is a message ready for output.
Derive from this class and implement this method.
| bool agx::LogStream::open | ( | const agx::String & | name | ) |
Open a specified file as a log.
| void agx::LogStream::setCallback | ( | CallbackFunction_t | f | ) |
Sets the function that will be called if FUNCTION is set as outputmode.
| void agx::LogStream::setDateFormat | ( | const agx::String & | date_format | ) |
Specify the format of the date/time string that getTimeString() will return Look at strftime for examples of how to specify the date.
Default is "%X" (hh:mm:ss)
| void agx::LogStream::setEnableDate | ( | bool | flag | ) |
If flag == true, the date in the specified date format will be added prior to each message.
| void agx::LogStream::setEnableThreadId | ( | bool | flag | ) |
If set to true, the messages will be prefixed with the id of the thread that generates the message.
| void agx::LogStream::setOutputMode | ( | short | modemask | ) |
Set the active outputmode to modemask.
|
protected |
|
protected |
Definition at line 137 of file LogStream.h.
|
protected |
Definition at line 140 of file LogStream.h.
|
protected |
Definition at line 142 of file LogStream.h.
|
protected |
Definition at line 141 of file LogStream.h.
|
protected |
Definition at line 139 of file LogStream.h.