Public Member Functions | Protected Attributes

wosh::LogHandlerPlainText Class Reference

Render log entries to plain text file (written on local host). More...

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

List of all members.

Public Member Functions

 LogHandlerPlainText ()
 Default constructor. Initialize vars.
virtual ~LogHandlerPlainText ()
 Destructor. Close the output (device) when still openend.
virtual void log (const char *context, LogLevel level, const char *format, va_list args)
 Log a generic message (using same format as printf). Reentrant.
virtual WRESULT open ()
 Open the output (device) for writing. Reentrant.
virtual WRESULT close ()
 Close the output (device). Reentrant.
virtual WRESULT flush ()
 Force writing the buffer to the output (device). Reentrant.
virtual bool isOpen () const
 Evaluate if the output (device) is open for writing. Reentrant.
virtual WRESULT setProtocol (const std::string &protocol_string)
 Configure the handler through protocol string. Reentrant.
virtual std::string getProtocol () const
 Get the current protocol string.
Getters
std::string getFileName () const
 Get current output filename. Reentrant.
Setters
WRESULT setFileName (const std::string &filename, bool append=true)
 Set current output filename. When handler is opened it will be closed and re-opened. Reentrant.

Protected Attributes

FILE * outFile
 reference of the current output FILE, may be NULL
std::string outFilename
 current output filename
bool appendMode
 file-mode flag, refer to a/w parameters of fopen

Detailed Description

Render log entries to plain text file (written on local host).

All methods of this class are reentrant.

Default output filename is default.log.

Protocol is file://FILENAME.

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

Definition at line 206 of file LogHandlers.h.


Constructor & Destructor Documentation

wosh::LogHandlerPlainText::LogHandlerPlainText (  ) [inline]

Default constructor. Initialize vars.

Definition at line 214 of file LogHandlers.h.

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

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

Definition at line 219 of file LogHandlers.h.

References close().


Member Function Documentation

WRESULT wosh::LogHandlerPlainText::close (  ) [virtual]

Close the output (device). Reentrant.

Returns:
WRET_OK on success; a custom error code else

Implements wosh::LogHandler.

Definition at line 201 of file LogHandlers.cpp.

Referenced by ~LogHandlerPlainText().

WRESULT wosh::LogHandlerPlainText::flush (  ) [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 206 of file LogHandlers.cpp.

References WRET_OK.

std::string wosh::LogHandlerPlainText::getFileName (  ) const [inline]

Get current output filename. Reentrant.

Returns:
string representing the filename

Definition at line 252 of file LogHandlers.h.

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

Referenced by wosh::DefaultSharedLogHandler::getFileName().

std::string wosh::LogHandlerPlainText::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 266 of file LogHandlers.cpp.

bool wosh::LogHandlerPlainText::isOpen (  ) const [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 260 of file LogHandlers.cpp.

void wosh::LogHandlerPlainText::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 274 of file LogHandlers.cpp.

References wosh::_GET_LogLevelIndex().

WRESULT wosh::LogHandlerPlainText::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 196 of file LogHandlers.cpp.

WRESULT wosh::LogHandlerPlainText::setFileName ( const std::string &  filename,
bool  append = true 
)

Set current output filename. When handler is opened it will be closed and re-opened. Reentrant.

Parameters:
filename[in] string representing the filename
append[in] when true it will open file for appending; else file will be replaced
Returns:
WRET_OK on success; WRET_ERR_INTERNAL if log was opened and close() returned an error; WRET_ERR_ILLEGAL_USE if log can't be opened

Definition at line 163 of file LogHandlers.cpp.

References WRET_ERR_ILLEGAL_USE, WRET_ERR_INTERNAL, and WRET_OK.

WRESULT wosh::LogHandlerPlainText::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 file://. Example: 'file://mylog.log'
Returns:
WRET_ERR_PARAM when prefix is missing or invalid; setFileName() return codes else
See also:
setFileName()

Implements wosh::LogHandler.

Definition at line 255 of file LogHandlers.cpp.

References WRET_ERR_PARAM.


Member Data Documentation

file-mode flag, refer to a/w parameters of fopen

Definition at line 277 of file LogHandlers.h.

reference of the current output FILE, may be NULL

Definition at line 275 of file LogHandlers.h.

std::string wosh::LogHandlerPlainText::outFilename [protected]

current output filename

Definition at line 276 of file LogHandlers.h.

Referenced by getFileName().


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