ApparatusFramework::Logger Class Reference
[Diagnostic Services]

#include <DiagnosticServices/current/include/Logger.h>

Inheritance diagram for ApparatusFramework::Logger:
ApparatusFramework::Monitor ApparatusFramework::DoubleDeviceLogger

List of all members.

Classes

struct  LogFilterItem

Public Types

enum  LogEvent {
  sendMsg, receiveMsg, writeMsg, readMsg,
  doTraceText, reserveMsg, releaseMsg, allMsgsReserved,
  noMsgReserved, noEvent
}

Public Member Functions

void printLogText (const char *aFormat,...)
void decompressAndPrintLogText_SimpleCoding (const unsigned char *form_spec,...)
void enableLogging (const bool isOn)
void setFilterState (const bool isFilterOn)
void registerFilter (const TaskId taskId, const LogEvent event)
void unregisterFilter (const TaskId taskId, const LogEvent event)
void clearAllFilters ()
void traceEvent (const TaskId taskId, const LogEvent event, Msg *msg)
void traceText (const TaskId taskId, const char *aFormat,...)
void setLogDevice (const char *logDeviceName="tty0")
void registerDeferredLogger (DeferredLogger *pDeferredLogger)
void unregisterDeferredLogger ()
bool getFilterState ()
bool isRegistered (const TaskId taskId, const LogEvent event)
const char * getEventSymbol (const LogEvent event) const

Static Public Member Functions

static LoggerCreate ()
static LoggerDefault ()
static bool IsCreated ()

Friends

class DoubleDeviceLogger

Detailed Description

The logger class provides basic logging mechanisms to trace activities of the apparatus framework and the user application. Logging is supported in the simulation environment (application running on the developer workstation) and on the embedded target.

The class is implemented as a monitor to be thread safe. As a side effect the events are logged in chronological order. All public methods are protected by the monitor mechanisms.

A filter mechanism allows selectively reducing the number of logged events at runtime.

Definition at line 207 of file Logger.h.


Member Enumeration Documentation

The enumeration defines all events handled by the logger.

Enumerator:
sendMsg 

enumeration values Event of sending a message from a task to another one.

receiveMsg 

Event of receiving a message from another task.

writeMsg 

Event of writing a message (without task switch).

readMsg 

Event of reading a message (without task switch).

doTraceText 

Event when a trace text is written in the code.

reserveMsg 

Event whenever a message is reserved.

releaseMsg 

Event whenever a message is released.

allMsgsReserved 

Event when a message cannot be reserved because the message pool is empty.

noMsgReserved 

Event when a message cannot be released because the message pool is full.

noEvent 

Only used internally.

Definition at line 213 of file Logger.h.


Member Function Documentation

void ApparatusFramework::Logger::clearAllFilters (  ) 

Clears all filters defined in the logger.

static Logger* ApparatusFramework::Logger::Create (  )  [static]

static functions Creates an instance of the singleton if none exists yet. The object is created in static memory.

Returns:
A pointer to the created singleton instance.

Reimplemented in ApparatusFramework::DoubleDeviceLogger.

void ApparatusFramework::Logger::decompressAndPrintLogText_SimpleCoding ( const unsigned char *  form_spec,
  ... 
)

Prints out text that is compressed with "Simple Coding" to the log device, regardless of any filter or enabling/disabling.

Parameters:
form_spec printf like string that supports formatting but the string must be compressed with "Simple Coding". The syntax for the formatted string is like printf with the extension for compressed string arguments: Use cs for compressed string arguments!
... printf like parameter list that supports formatting of the string. Argument list: Compressed string parameter or standard parameters like printf.
static Logger* ApparatusFramework::Logger::Default (  )  [static]

Returns the registered singleton instance.

Returns:
The registered logger instance. If none is registered null is returned.

Reimplemented in ApparatusFramework::DoubleDeviceLogger.

void ApparatusFramework::Logger::enableLogging ( const bool  isOn  ) 

Prints out text that is compressed with "Huffman Coding" to the log device, regardless of any filter or enabling/disabling.

Parameters:
form_spec printf like string that supports formatting but the string must be compressed with "Huffman Coding". The syntax for the formatted string is like printf with the extension for compressed string arguments: Use cs for compressed string arguments!
... printf like parameter list that supports formatting of the string. Argument list: Compressed string parameter or standard parameters like printf. Switches the log trace on and off. This method can be used to globaly enable and disable the trace generation.
isOn true if logging should be performed otherwise false.
const char* ApparatusFramework::Logger::getEventSymbol ( const LogEvent  event  )  const

Returns the string used to indicate a certain event.

Parameters:
event the logger event.
Returns:
The symbol that should be used to indicate the specified event.
bool ApparatusFramework::Logger::getFilterState (  ) 

queries Returns the state of the filtering function. The function is not declared constant due to the limitations of the monitor implementation.

Returns:
State of the filtering function.
static bool ApparatusFramework::Logger::IsCreated (  )  [static]

States whether an instance of this singleton has been created.

Returns:
True if an instance has been created, false otherwise.

Reimplemented in ApparatusFramework::DoubleDeviceLogger.

bool ApparatusFramework::Logger::isRegistered ( const TaskId  taskId,
const LogEvent  event 
)

Returns true if the task is registered for the given log event.

Parameters:
taskId identifier of the task.
event event on which the logger should react.
Returns:
bool True if the event is registered for this event otherwise false.
void ApparatusFramework::Logger::printLogText ( const char *  aFormat,
  ... 
)

modifiers Prints out text to the log device, regardless of any filter or enabling/disabling. As long as there is no log device set, vprintf is used directly.

Parameters:
aFormat printf like string that supports formatting.
... printf like parameter list that supports formatting of the string.
void ApparatusFramework::Logger::registerDeferredLogger ( DeferredLogger pDeferredLogger  ) 

Registers a deferred logger.

Parameters:
pDeferredLogger pointer to deferred logger, which has to be registered.
void ApparatusFramework::Logger::registerFilter ( const TaskId  taskId,
const LogEvent  event 
)

Registers the filter for the task and the associated event. If the filtering functions are enabled, only registered events will be logged.

Parameters:
taskId identifier of the task.
event event on which the logger should react.
void ApparatusFramework::Logger::setFilterState ( const bool  isFilterOn  ) 

Sets the new status of the filtering function. If the filter is activated only events associated with registered tasks are traced.

Parameters:
isFilterOn new state of the filter function.
void ApparatusFramework::Logger::setLogDevice ( const char *  logDeviceName = "tty0"  ) 

Sets the CharDevice the logged messages are sent to. Please make sure that the specified device is registered with the DeviceMgr before calling this method.

Parameters:
logDeviceName name of the CharDevice, "tty0" by default.
Note:
This method is only available if the DeviceServices package is added to the ApparatusFramework library.
void ApparatusFramework::Logger::traceEvent ( const TaskId  taskId,
const LogEvent  event,
Msg msg 
)

Traces the event generated by the task with the given task identifier. The associated on method is only called if the filter configuration allows it.

Parameters:
taskId identifier of the task.
event event on which the logger should react.
msg message used when the event was generated.
void ApparatusFramework::Logger::traceText ( const TaskId  taskId,
const char *  aFormat,
  ... 
)

Traces the text generated by the given task. The associated method is only called if the filter configuration allows it.

Parameters:
taskId identifier of the task.
aFormat printf like string that supports formatting. Has to be a string literal!
.... printf like parameter list that supports formatting of the string.
void ApparatusFramework::Logger::unregisterDeferredLogger (  ) 

Unregisters a deferred logger.

void ApparatusFramework::Logger::unregisterFilter ( const TaskId  taskId,
const LogEvent  event 
)

Unregisters the filter for the task and the associated event. If the filtering functions are enabled, only registered events will be logged.

Parameters:
taskId identifier of the task.
event event on which the logger should react.

Friends And Related Function Documentation

friend class DoubleDeviceLogger [friend]

Definition at line 208 of file Logger.h.

© 2004-2010 bbv Software Services AG / Apparatus Services