Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Attributes | Friends

wosh::LogHandler Class Reference
[Core-Interfaces]

Base (abstract) class of a generic log-output renderer. More...

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

List of all members.

Public Member Functions

 LogHandler ()
 Default constructor. Assign ID and register instance to global list (reentrant).
virtual ~LogHandler ()
 Destructor. Unregister instance from global list (reentrant)
virtual void log (const char *context, LogLevel level, const char *format, va_list args)=0
 Log a generic message (using same format as printf). Reentrant.
virtual WRESULT open ()=0
 Open the output (device) for writing. Reentrant.
virtual WRESULT close ()=0
 Close the output (device). Reentrant.
virtual WRESULT flush ()=0
 Force writing the buffer to the output (device). Reentrant.
virtual bool isOpen () const =0
 Evaluate if the output (device) is open for writing. Reentrant.
virtual WRESULT setProtocol (const std::string &protocol_string)=0
 Set the current protocol string: a standard way to reconfigure handler.
virtual std::string getProtocol () const =0
 Get the current protocol string.
Getters
long getID () const
 Get ID of the handler.
int getLogLevelMask () const

Protected Member Functions

void bufferTime (const char *format)
 Render current (local) timestamp to internal buffer.

Static Protected Member Functions

static tLogHandlerListgetInstances ()
 Get instances of LogHandler implementations. Meyer singleton.

Protected Attributes

long id
 unique id of the handler (random positive long)
MutexRW configMux
 mutex of previous vars
char bufferDateTime [32]
 buffer of the timestamp
int maskLevel
 buffer of the timestamp
Mutex writeMux
 mutex of the write operation

Private Attributes

bool skip_unregister_instance
 when true it won't unregister instance on destructor, used *only* by SystemLogger

Friends

class wosh::SystemLogger

Detailed Description

Base (abstract) class of a generic log-output renderer.

Implementations must be (fully) thread safe (reentrant).

Log entries are usually formatted as: LEVEL TIMESTAMP CONTEXT(+indentation) CONTENT

See also:
wosh::LogContext
wosh::SystemLogger, Logging
Version:
0.8.499
Id:
LogHandlers.h 3775 2011-01-01 16:38:17Z alex
Author:
Alessandro Polo

Definition at line 66 of file LogHandlers.h.


Constructor & Destructor Documentation

wosh::LogHandler::LogHandler (  )

Default constructor. Assign ID and register instance to global list (reentrant).

See also:
LogHandler::getInstances()

Definition at line 83 of file LogHandlers.cpp.

References wosh::LOG_ALL.

wosh::LogHandler::~LogHandler (  ) [virtual]

Destructor. Unregister instance from global list (reentrant)

See also:
skip_unregister_instance
LogHandler::getInstances()

Definition at line 90 of file LogHandlers.cpp.


Member Function Documentation

void wosh::LogHandler::bufferTime ( const char *  format ) [protected]

Render current (local) timestamp to internal buffer.

Parameters:
format[in] format of the output
See also:
localtime()
strftime()

Definition at line 96 of file LogHandlers.cpp.

virtual WRESULT wosh::LogHandler::close (  ) [pure virtual]

Close the output (device). Reentrant.

Returns:
WRET_OK on success; a custom error code else

Implemented in wosh::LogHandlerPlainText, wosh::LogHandlerStdOut, wosh::LogHandlerMultiplexer< COUNT >, wosh::gui::LogHandlerQRenderer, and wosh::LogHandlerMultiplexer< 4 >.

Referenced by wosh::LogHandlerMultiplexer< 4 >::close().

virtual WRESULT wosh::LogHandler::flush (  ) [pure 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

Implemented in wosh::LogHandlerPlainText, wosh::LogHandlerStdOut, wosh::LogHandlerMultiplexer< COUNT >, wosh::gui::LogHandlerQRenderer, and wosh::LogHandlerMultiplexer< 4 >.

Referenced by wosh::LogHandlerMultiplexer< 4 >::flush().

long wosh::LogHandler::getID (  ) const [inline]

Get ID of the handler.

Returns:
unique ID of the handler

Definition at line 153 of file LogHandlers.h.

References id.

Referenced by wosh::LogHandlerMultiplexer< 4 >::getProtocol().

LogHandler::tLogHandlerList & wosh::LogHandler::getInstances (  ) [static, protected]

Get instances of LogHandler implementations. Meyer singleton.

Returns:
static reference to instances' list. Allocated on first use (reentrant after that).

Definition at line 75 of file LogHandlers.cpp.

virtual std::string wosh::LogHandler::getProtocol (  ) const [pure virtual]

Get the current protocol string.

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

Implemented in wosh::LogHandlerPlainText, wosh::LogHandlerStdOut, wosh::LogHandlerMultiplexer< COUNT >, wosh::gui::LogHandlerQRenderer, and wosh::LogHandlerMultiplexer< 4 >.

virtual bool wosh::LogHandler::isOpen (  ) const [pure 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()

Implemented in wosh::LogHandlerPlainText, wosh::LogHandlerStdOut, wosh::LogHandlerMultiplexer< COUNT >, wosh::gui::LogHandlerQRenderer, and wosh::LogHandlerMultiplexer< 4 >.

virtual void wosh::LogHandler::log ( const char *  context,
LogLevel  level,
const char *  format,
va_list  args 
) [pure 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

Implemented in wosh::LogHandlerPlainText, wosh::LogHandlerStdOut, wosh::LogHandlerMultiplexer< COUNT >, wosh::gui::LogHandlerQRenderer, and wosh::LogHandlerMultiplexer< 4 >.

Referenced by wosh::LogHandlerMultiplexer< 4 >::log().

virtual WRESULT wosh::LogHandler::open (  ) [pure virtual]

Open the output (device) for writing. Reentrant.

Returns:
WRET_OK on success; a custom error code else

Implemented in wosh::LogHandlerPlainText, wosh::LogHandlerStdOut, wosh::LogHandlerMultiplexer< COUNT >, wosh::gui::LogHandlerQRenderer, and wosh::LogHandlerMultiplexer< 4 >.

Referenced by wosh::LogHandlerMultiplexer< 4 >::open().

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

Set the current protocol string: a standard way to reconfigure handler.

Parameters:
protocol_string[in] literal string representing log-handler type and its settings, separator is '://'
Returns:
WRET_OK on success; a custom error code else
Note:

Implemented in wosh::LogHandlerPlainText, wosh::LogHandlerStdOut, wosh::LogHandlerMultiplexer< COUNT >, wosh::gui::LogHandlerQRenderer, and wosh::LogHandlerMultiplexer< 4 >.


Member Data Documentation

char wosh::LogHandler::bufferDateTime[32] [protected]

buffer of the timestamp

Definition at line 170 of file LogHandlers.h.

long wosh::LogHandler::id [protected]

unique id of the handler (random positive long)

Definition at line 168 of file LogHandlers.h.

Referenced by getID().

int wosh::LogHandler::maskLevel [protected]

buffer of the timestamp

Definition at line 171 of file LogHandlers.h.

when true it won't unregister instance on destructor, used *only* by SystemLogger

Definition at line 181 of file LogHandlers.h.

mutex of the write operation

Definition at line 172 of file LogHandlers.h.

Referenced by wosh::LogHandlerMultiplexer< 4 >::log().


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