Frapper  1.0a
Public Types | Static Public Member Functions | Private Types | Static Private Member Functions | Static Private Attributes | List of all members
Frapper::Log Class Reference

Static class for managing log messages. More...

#include <Log.h>

Public Types

enum  MessageType {
  MT_Info = 1, MT_Warning = 2, MT_Error = 4, MT_Debug = 8,
  MT_Qt = 16, MT_Ogre = 32
}
 Nested enumeration for the different types of log messages. More...
 

Static Public Member Functions

static void initialize (bool useStandardStreams)
 Initializes private static data of the log message handler.
 
static void finalize ()
 Frees all resources that were used by private static data of the log message handler.
 
static void loadIcons ()
 Loads the icons for the different log message types.
 
static void registerView (QTableView *tableView)
 Registers the given table view as an output widget for log messages.
 
static void unregisterView (QTableView *tableView)
 Unregisters the given table view from the log message handler.
 
static void info (const QString &message, const QString &function="")
 Adds the given text to the list of informational log messages.
 
static void warning (const QString &message, const QString &function="")
 Adds the given text to the list of warning log messages.
 
static void error (const QString &message, const QString &function="")
 Adds the given text to the list of error log messages.
 
static void debug (const QString &message, const QString &function="")
 Adds the given text to the list of debugging log messages.
 
static void na (const QString &function="")
 Adds a message to the list of warning log messages that the selected function is not available yet.
 
static void addQtLogMessage (QtMsgType qtMessageType, const char *qtMessage)
 Adds the given text to the list of Qt log messages.
 
static void addOgreLogMessage (const QString &message, const QString &logMessageLevel)
 Adds the given text to the list of OGRE log messages.
 
static void setFilterEnabled (QTableView *tableView, bool enabled)
 Toggles filtering of log messages for the given table view.
 
static void filter (QTableView *tableView, MessageType type, bool visible)
 Toggles a specific type of log messages in the given table view by making these messages visible or invisible.
 
static void filter (QTableView *tableView, const QString &searchText)
 Filters log messages in the given table view by using a reg expression.
 
static void clear ()
 Clears the history of log messages.
 
static QString getMessage (QStandardItemModel *model, int row)
 Builds a string representing the message with the given row index in the given item model.
 

Private Types

typedef QMap< int,
QStandardItemModel * > 
MessageModelMap
 Type definition for a map of message models by message type mask.
 
typedef QMap< int,
QSortFilterProxyModel * > 
ProxyModelMap
 Type definition for a map of proxy models by message type mask.
 
typedef QMap< Log::MessageType,
bool > 
MessageFilters
 Type definition for a map of log message types along with their activation values.
 
typedef QPair< bool,
MessageFilters
FilterSettings
 Type definition for a boolean value stating whether message filtering is enabled at all and the filters for the individual log message types.
 
typedef QMap< QTableView
*, FilterSettings
TableViewMap
 Type definition for the map of table views registered with the log message handler along with their filter settings.
 

Static Private Member Functions

static void addMessage (MessageType messageType, const QString &message, const QString &function="")
 Adds the given text to the list of log messages.
 
static void updateModel (QTableView *tableView)
 Fills the model that is used in the given table view with messages of types according to the active view filters.
 
static void printToStandardOutput (const QString &header, const QString &message, const QString &function)
 Writes the given message preceeded by the given header text and the given function name (if available) to the standard output stream.
 
static void printToStandardError (const QString &header, const QString &message, const QString &function)
 Writes the given message preceeded by the given header text and the given function name (if available) to the standard error stream.
 

Static Private Attributes

static bool s_useStandardStreams = false
 Flag that states whether log messages should also be written to stdout and stderr.
 
static bool s_initialized = false
 Flag that states whether the log message handler has been initialized.
 
static QStringList s_headerLabels
 The list of header labels for the standard item models.
 
static MessageModelMap s_messageModels
 The map of standard item models for all combinations of log message types.
 
static ProxyModelMap s_proxyModels
 The map of proxy models for all combinations of log message types.
 
static TableViewMap s_tableViews
 The nested map for storing registered table views and their message filters.
 
static QMap< MessageType, QIcon > s_messageIcons
 The list of icons for the different log message types.
 

Detailed Description

Static class for managing log messages.

Member Typedef Documentation

typedef QMap<int, QStandardItemModel *> Frapper::Log::MessageModelMap
private

Type definition for a map of message models by message type mask.

typedef QMap<int, QSortFilterProxyModel *> Frapper::Log::ProxyModelMap
private

Type definition for a map of proxy models by message type mask.

typedef QMap<Log::MessageType, bool> Frapper::Log::MessageFilters
private

Type definition for a map of log message types along with their activation values.

typedef QPair<bool, MessageFilters> Frapper::Log::FilterSettings
private

Type definition for a boolean value stating whether message filtering is enabled at all and the filters for the individual log message types.

typedef QMap<QTableView *, FilterSettings> Frapper::Log::TableViewMap
private

Type definition for the map of table views registered with the log message handler along with their filter settings.

Member Enumeration Documentation

Nested enumeration for the different types of log messages.

Enumerator:
MT_Info 
MT_Warning 
MT_Error 
MT_Debug 
MT_Qt 
MT_Ogre 

Member Function Documentation

void Frapper::Log::initialize ( bool  useStandardStreams)
static

Initializes private static data of the log message handler.

Public Static Functions.

Parameters
useStandardStreamsFlag to control whether to also output log messages to stdout and stderr.

Initializes private static data of the log message handler.

Parameters
useStandardStreamsFlag to control whether to also output log messages to stdout and stderr.
void Frapper::Log::finalize ( )
static

Frees all resources that were used by private static data of the log message handler.

void Frapper::Log::loadIcons ( )
static

Loads the icons for the different log message types.

void Frapper::Log::registerView ( QTableView *  tableView)
static

Registers the given table view as an output widget for log messages.

Parameters
tableViewThe table view to register as an output widget.
void Frapper::Log::unregisterView ( QTableView *  tableView)
static

Unregisters the given table view from the log message handler.

Parameters
tableViewThe table view to unregister from the log message handler.
void Frapper::Log::info ( const QString &  message,
const QString &  function = "" 
)
static

Adds the given text to the list of informational log messages.

Parameters
messageThe text to add as an informational log message.
functionThe signature of the function that is reporting the message.
void Frapper::Log::warning ( const QString &  message,
const QString &  function = "" 
)
static

Adds the given text to the list of warning log messages.

Parameters
messageThe text to add as a warning log message.
functionThe signature of the function that is reporting the message.
void Frapper::Log::error ( const QString &  message,
const QString &  function = "" 
)
static

Adds the given text to the list of error log messages.

Parameters
messageThe text to add as an error log message.
functionThe signature of the function that is reporting the message.
void Frapper::Log::debug ( const QString &  message,
const QString &  function = "" 
)
static

Adds the given text to the list of debugging log messages.

Parameters
messageThe text to add as a debugging log message.
functionThe signature of the function that is reporting the message.
void Frapper::Log::na ( const QString &  function = "")
static

Adds a message to the list of warning log messages that the selected function is not available yet.

Parameters
functionThe signature of the function that is reporting the message.
void Frapper::Log::addQtLogMessage ( QtMsgType  qtMessageType,
const char *  qtMessage 
)
static

Adds the given text to the list of Qt log messages.

Parameters
qtMessageTypeThe type of the Qt message.
qtMessageThe message text.
void Frapper::Log::addOgreLogMessage ( const QString &  message,
const QString &  logMessageLevel 
)
static

Adds the given text to the list of OGRE log messages.

Parameters
messageThe text to add as an OGRE log message.
logMessageLevelThe importance of the logged message.
void Frapper::Log::setFilterEnabled ( QTableView *  tableView,
bool  enabled 
)
static

Toggles filtering of log messages for the given table view.

Parameters
tableViewThe table view to enable or disable filtering for.
enabledFlag that controls whether to enable or disable filtering.
enabledFlag that controls whether to enable or disable filtering.
void Frapper::Log::filter ( QTableView *  tableView,
MessageType  type,
bool  visible 
)
static

Toggles a specific type of log messages in the given table view by making these messages visible or invisible.

Parameters
tableViewThe table view to filter messages in.
typeThe type of log messages to filter.
visibleFlag that controls whether to hide or show the messages.
void Frapper::Log::filter ( QTableView *  tableView,
const QString &  searchText 
)
static

Filters log messages in the given table view by using a reg expression.

Parameters
searchTextThe search text.
void Frapper::Log::clear ( )
static

Clears the history of log messages.

QString Frapper::Log::getMessage ( QStandardItemModel *  model,
int  row 
)
static

Builds a string representing the message with the given row index in the given item model.

Returns
A string representing the message with the given row index in the given item model.
void Frapper::Log::addMessage ( MessageType  messageType,
const QString &  message,
const QString &  function = "" 
)
staticprivate

Adds the given text to the list of log messages.

Private Static Functions.

Parameters
messageTypeThe type of log message to add.
messageThe text to add as a log message.
functionThe signature of the function that is reporting the message.

Adds the given text to the list of log messages.

Parameters
messageTypeThe type of log message to add.
messageThe text to add as a log message.
functionThe signature of the function that is reporting the message.
void Frapper::Log::updateModel ( QTableView *  tableView)
staticprivate

Fills the model that is used in the given table view with messages of types according to the active view filters.

Parameters
tableViewThe table view whose model to fill with log messages.
void Frapper::Log::printToStandardOutput ( const QString &  header,
const QString &  message,
const QString &  function 
)
staticprivate

Writes the given message preceeded by the given header text and the given function name (if available) to the standard output stream.

Parameters
headerThe text to put before the message.
messageThe message to write to the standard output stream.
functionThe name of a function that reported the message.
void Frapper::Log::printToStandardError ( const QString &  header,
const QString &  message,
const QString &  function 
)
staticprivate

Writes the given message preceeded by the given header text and the given function name (if available) to the standard error stream.

Parameters
headerThe text to put before the message.
messageThe message to write to the standard error stream.
functionThe name of a function that reported the message.

Member Data Documentation

bool Frapper::Log::s_useStandardStreams = false
staticprivate

Flag that states whether log messages should also be written to stdout and stderr.

Private Static Data.

bool Frapper::Log::s_initialized = false
staticprivate

Flag that states whether the log message handler has been initialized.

QStringList Frapper::Log::s_headerLabels
staticprivate

The list of header labels for the standard item models.

Log::MessageModelMap Frapper::Log::s_messageModels
staticprivate

The map of standard item models for all combinations of log message types.

Log::ProxyModelMap Frapper::Log::s_proxyModels
staticprivate

The map of proxy models for all combinations of log message types.

The map of proxy item models for all combinations of log message types.

Log::TableViewMap Frapper::Log::s_tableViews
staticprivate

The nested map for storing registered table views and their message filters.

QMap< Log::MessageType, QIcon > Frapper::Log::s_messageIcons
staticprivate

The list of icons for the different log message types.


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