17#ifndef AGX_LOGSTREAM_H
18#define AGX_LOGSTREAM_H
22# pragma warning(disable: 4355)
23# pragma warning(disable: 4251)
53 typedef void ( *CallbackFunction_t )(
const char*,
unsigned int );
85 enum OutputMode { CERR = 1, COUT = 2, FILE = 4, FUNCTION = 8 };
131 virtual void message(
const char* msg,
unsigned int length );
135 size_t write(
const char *msg, std::streamsize count);
154 bool m_threadId_enabled;
159 template < class logStreamT, class charT, class traits =
std::char_traits<charT> >
164 LogBuf( logStreamT* stream ) : m_stream( stream ) {}
169 typedef LogBuf<logStreamT, charT> classT;
170 typedef std::basic_streambuf<charT, traits> BaseClassT;
172 std::streamsize output(
const char* pStr, std::streamsize n );
174 int overflow (
int ch );
178 LogBuf(
const LogBuf& );
179 LogBuf& operator=(
const LogBuf& );
180 logStreamT* m_stream;
181 std::ostringstream m_strStream;
185 typedef LogBuf<LogStream, char> LogBufT;
188 template <
class logStreamT,
class charT,
class traits >
friend class LogBuf;
Class for printing out messages to console, file, virtual method and or a callback function.
void setEnableDate(bool flag)
If flag == true, the date in the specified date format will be added prior to each message.
void appendOutputMode(short modemask)
OR:s together the active outputmode with modemask.
void setOutputMode(short modemask)
Set the active outputmode to modemask.
void setCallback(CallbackFunction_t f)
Sets the function that will be called if FUNCTION is set as outputmode.
const agx::String & getDateFormat() const
bool getEnableDate() const
virtual ~LogStream()
Flush and empty all buffers, and then remove the allocated buffers.
LogStream & operator=(const LogStream &)
void clearOutputMode(void)
Resets the active output modes to none.
agx::String getFilename() const
LogStream(const LogStream &)
void setEnableThreadId(bool flag)
If set to true, the messages will be prefixed with the id of the thread that generates the message.
CallbackFunction_t m_callback
OutputMode
Enums used to specify the output mode used. These can be OR:ed together.
static agx::String getTimeString(const agx::String &dateFormat="", bool logTimeWithMilliseconds=true)
bool isActive(OutputMode modemask)
Returns true if the modemask is set as the active output mode.
void setDateFormat(const agx::String &date_format)
Specify the format of the date/time string that getTimeString() will return Look at strftime for exam...
CallbackFunction_t getCallback()
virtual void message(const char *msg, unsigned int length)
This method will be called whenever there is a message ready for output.
bool open(const agx::String &name)
Open a specified file as a log.
size_t write(const char *msg, std::streamsize count)
int getOutputMode(void)
Returns the active outputmode.
bool haveOpenFile() const
bool getEnableThreadId() const
#define DOXYGEN_END_INTERNAL_BLOCK()
#define DOXYGEN_START_INTERNAL_BLOCK()
The agx namespace contains the dynamics/math part of the AGX Dynamics API.