Public Member Functions | Static Public Member Functions | Protected Attributes

wosh::LogHandlerStdOut Class Reference

Render log entries to stdout (default console output). More...

#include <H:/WOSH/win32_vc2010/src/core/LogHandlers.h>

List of all members.

Public Member Functions

 LogHandlerStdOut ()
 Default constructor. Initialize vars, set (default) output to stderr.
virtual ~LogHandlerStdOut ()
 Destructor. Close the output (device) when still openend.
void log (const char *context, LogLevel level, const char *format, va_list args)
 Log a generic message (using same format as printf). Reentrant.
WRESULT open ()
 Open the output (device) for writing. Reentrant.
WRESULT close ()
 Close the output (device). Reentrant.
WRESULT flush ()
 Force writing the buffer to the output (device). Reentrant.
bool isOpen () const
 Evaluate if the output (device) is open for writing. Reentrant.
WRESULT setProtocol (const std::string &protocol_string)
 Configure the handler through protocol string. Reentrant.
std::string getProtocol () const
 Get the current protocol string.
Getters
bool isColoured () const
 Evaluate if the output is coloured. Reentrant.
Setters
void setColoured (bool enabled=true)
 Enable/Disable coloured output. Reentrant.

Static Public Member Functions

static LogHandlerStdOutgetInstance ()
 Get the singleton instance. Meyer singleton.

Protected Attributes

FILE * outStd
 reference to current output. since stdout/stderr are just FILE*
bool printColoured
 flag, when true it will print coloured messages

Detailed Description

Render log entries to stdout (default console output).

The implementation is very similar to wosh::LogHandlerPlainText, but has been customized for stdout features.

All methods of this class are reentrant.

On Windows and POSIX systems, outpur may be coloured (depends on LogLevel).

Version:
0.8.499
Id:
LogHandlers.h 3775 2011-01-01 16:38:17Z alex
Author:
Alessandro Polo

Definition at line 299 of file LogHandlers.h.


Constructor & Destructor Documentation

wosh::LogHandlerStdOut::LogHandlerStdOut (  ) [inline]

Default constructor. Initialize vars, set (default) output to stderr.

Note:
This handler should be allocated (internally) calling getInstance()
See also:
LogHandlerStdOut::getInstance()

Definition at line 309 of file LogHandlers.h.

virtual wosh::LogHandlerStdOut::~LogHandlerStdOut (  ) [inline, virtual]

Destructor. Close the output (device) when still openend.

Definition at line 314 of file LogHandlers.h.

References close().


Member Function Documentation

WRESULT wosh::LogHandlerStdOut::close (  ) [inline, virtual]

Close the output (device). Reentrant.

Returns:
WRET_OK on success; a custom error code else

Implements wosh::LogHandler.

Definition at line 330 of file LogHandlers.h.

References WRET_OK.

Referenced by ~LogHandlerStdOut().

WRESULT wosh::LogHandlerStdOut::flush (  ) [inline, virtual]

Force writing the buffer to the output (device). Reentrant.

Returns:
WRET_OK on success; a custom error code else
Note:
really works only for buffered device/wrappers

Implements wosh::LogHandler.

Definition at line 331 of file LogHandlers.h.

References WRET_OK.

LogHandlerStdOut * wosh::LogHandlerStdOut::getInstance (  ) [static]

Get the singleton instance. Meyer singleton.

Returns:
Static pointer to singleton instance, allocated on first use and destroyed by the system

Definition at line 353 of file LogHandlers.cpp.

std::string wosh::LogHandlerStdOut::getProtocol (  ) const [virtual]

Get the current protocol string.

Returns:
literal string representing log-handler type and its settings, separator is '://'

Implements wosh::LogHandler.

Definition at line 379 of file LogHandlers.cpp.

bool wosh::LogHandlerStdOut::isColoured (  ) const [inline]

Evaluate if the output is coloured. Reentrant.

Returns:
true when messages are coloured; false else

Definition at line 353 of file LogHandlers.h.

References wosh::LogHandler::configMux, and printColoured.

bool wosh::LogHandlerStdOut::isOpen (  ) const [inline, virtual]

Evaluate if the output (device) is open for writing. Reentrant.

Returns:
true when the device is ready and valid for writing; false else
Note:
open()

Implements wosh::LogHandler.

Definition at line 334 of file LogHandlers.h.

void wosh::LogHandlerStdOut::log ( const char *  context,
LogLevel  level,
const char *  format,
va_list  args 
) [virtual]

Log a generic message (using same format as printf). Reentrant.

Parameters:
context[in] c string representing the log-context, may be NULL
level[in] LogLevel of the message
format[in] c string that contains the text to be written
args[in] variable-arguments parameter

Implements wosh::LogHandler.

Definition at line 391 of file LogHandlers.cpp.

References wosh::_GET_LogLevelIndex().

WRESULT wosh::LogHandlerStdOut::open (  ) [virtual]

Open the output (device) for writing. Reentrant.

Returns:
WRET_OK on success; a custom error code else

Implements wosh::LogHandler.

Definition at line 359 of file LogHandlers.cpp.

void wosh::LogHandlerStdOut::setColoured ( bool  enabled = true )

Enable/Disable coloured output. Reentrant.

Parameters:
enabled[in] true when messages are coloured; false else
Note:
coloured output is actually available on POSIX and Windows platforms only.

Definition at line 386 of file LogHandlers.cpp.

WRESULT wosh::LogHandlerStdOut::setProtocol ( const std::string &  protocol_string ) [virtual]

Configure the handler through protocol string. Reentrant.

Parameters:
protocol_string[in] literal string representing new settings, prefix must be std://. Examples: 'std://stdout', 'std://stderr'
Returns:
WRET_ERR_PARAM when prefix is missing or invalid; setFileName() return codes else

Implements wosh::LogHandler.

Definition at line 370 of file LogHandlers.cpp.

References WRET_ERR_PARAM, and WRET_OK.


Member Data Documentation

FILE* wosh::LogHandlerStdOut::outStd [protected]

reference to current output. since stdout/stderr are just FILE*

Definition at line 373 of file LogHandlers.h.

flag, when true it will print coloured messages

Definition at line 374 of file LogHandlers.h.

Referenced by isColoured().


The documentation for this class was generated from the following files:

Generated on Tue Feb 8 2011 09:33:30 for WOSH system 0.8.888 [wolf] by Alessandro Polo, using DoxyGen 1.7.2 hosted by WOSH Framework