ACF $AcfVersion:0$
Public Types | Protected Member Functions | List of all members
ilog::TLoggerCompWrap< Base > Class Template Reference

Template wrapper adding comprehensive logging functionality to components. More...

#include <TLoggerCompWrap.h>

Inheritance diagram for ilog::TLoggerCompWrap< Base >:
ilog::CLoggerBase ilog::ILoggable istd::ILogger istd::IPolymorphic istd::IPolymorphic ibase::CConsoleApplicationComp idoc::CMultiPageDocumentFilePersistenceComp ifile::CAutoPersistenceComp ifile::CFileListProviderComp ifile::CFileSystemInfoProviderComp ifile::TDeviceBasedSerializerComp< ReadArchive, WriteArchive > ifilegui::CFileDialogLoaderComp iimg::CBitmapLoaderComp ipackage::CPackagesLoaderComp ipackage::CRegistriesManagerComp ipackage::CRegistryCodeSaverComp iqt::CClipboardSerializerComp iqt::CSettingsSerializerComp iqt::CTranslationManagerComp iqtgui::CProcessStartCommandComp

Public Types

typedef Base BaseClass
 Base class typedef for component functionality.
 
typedef ilog::CLoggerBase BaseClass2
 Base class typedef for logger functionality.
 

Protected Member Functions

bool IsVerboseEnabled (int tracingLevel=0) const
 Check if verbose messages are enabled for a given tracing level.
 
void SendVerboseMessage (const QString &message, const QString &messageSource=QString(), int tracingLevel=0) const
 Send a verbose message if enabled.
 
virtual void DecorateMessage (istd::IInformationProvider::InformationCategory category, int id, int flags, QString &message, QString &messageSource) const override
 Decorate message before sending.
 
virtual void OnComponentCreated () override
 Called when component is created.
 
virtual void OnComponentDestroyed () override
 Called when component is destroyed.
 
- Protected Member Functions inherited from ilog::CLoggerBase
bool SendInfoMessage (int id, const QString &message, const QString &messageSource=QString(), int flags=0) const
 Send info message to log.
 
bool SendWarningMessage (int id, const QString &message, const QString &messageSource=QString(), int flags=0) const
 Send warning message to log.
 
bool SendErrorMessage (int id, const QString &message, const QString &messageSource=QString(), int flags=0) const
 Send error message to log.
 
bool SendCriticalMessage (int id, const QString &message, const QString &messageSource=QString(), int flags=0) const
 Send critical message to log.
 
bool SendInfoMessageOnce (int id, const QString &message, const QString &messageSource=QString(), int flags=0) const
 Send once info message to log.
 
bool SendWarningMessageOnce (int id, const QString &message, const QString &messageSource=QString(), int flags=0) const
 Send once warning message to log.
 
bool SendErrorMessageOnce (int id, const QString &message, const QString &messageSource=QString(), int flags=0) const
 Send once error message to log.
 
bool SendCriticalMessageOnce (int id, const QString &message, const QString &messageSource=QString(), int flags=0) const
 Send once critical message to log.
 
bool SendUserMessage (const istd::IInformationProvider *messagePtr) const
 Send message with user object.
 
bool AllowMessageOnceAgain (int id)
 Reset message lock.
 
virtual bool IsLogConsumed (const istd::IInformationProvider::InformationCategory *categoryPtr=NULL, const int *flagsPtr=NULL) const override
 Check if any log message is consumed.
 
virtual bool SendLogMessage (istd::IInformationProvider::InformationCategory category, int id, const QString &message, const QString &messageSource, int flags=0) const override
 Send any message to log.
 

Additional Inherited Members

- Public Member Functions inherited from ilog::CLoggerBase
 CLoggerBase ()
 Default constructor.
 
virtual void SetLogPtr (ilog::IMessageConsumer *logPtr) override
 Attach a message consumer for logging.
 
virtual ilog::IMessageConsumerGetLogPtr () const override
 Get the currently attached message consumer.
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 
- Protected Attributes inherited from ilog::CLoggerBase
QSet< int > m_onceMessageIds
 

Detailed Description

template<class Base>
class ilog::TLoggerCompWrap< Base >

Template wrapper adding comprehensive logging functionality to components.

TLoggerCompWrap combines any component base class with CLoggerBase to provide full logging capabilities. It automatically integrates with the ACF component system, managing log consumer connections, verbose message support, tracing configuration, and message source decoration.

This is one of the most commonly used templates in the ilog library, providing the standard way to add logging to ACF components.

Template Parameters
BaseBase component class to extend with logging (typically icomp::CComponentBase or a derived class)
Features
  • Automatic log consumer connection via "Log" reference
  • Verbose message support with configurable enable/disable
  • Tracing level integration for granular verbose control
  • Automatic component ID decoration of message sources
  • All CLoggerBase convenience methods (SendInfoMessage, SendErrorMessage, etc.)
  • "Send once" message variants to prevent log spam
  • Customizable message decoration
Component References
Component Attributes
  • EnableVerbose: Enable/disable verbose messages (default: false)
  • ShowComponentId: Include component ID in message source (default: true)
Usage Example
// Define component with logging
class MyComponent : public ilog::TLoggerCompWrap<icomp::CComponentBase>
{
public:
I_BEGIN_COMPONENT(MyComponent);
// ... component definition ...
I_END_COMPONENT;
void ProcessData() {
// Standard logging
SendInfoMessage(1001, "Processing started", "ProcessData");
try {
// ... processing ...
SendInfoMessage(1002, "Processing completed", "ProcessData");
}
catch (const std::exception& e) {
SendErrorMessage(1003,
QString("Processing failed: %1").arg(e.what()),
"ProcessData");
}
}
void DetailedOperation() {
// Verbose message (only if enabled)
SendVerboseMessage("Starting detailed operation", "DetailedOperation");
// Tracing level 1 (only if tracing >= 1)
if (IsVerboseEnabled(1)) {
SendVerboseMessage("Step 1 complete", "DetailedOperation", 1);
}
// Tracing level 2 (only if tracing >= 2)
if (IsVerboseEnabled(2)) {
SendVerboseMessage("Very detailed info", "DetailedOperation", 2);
}
}
};
Template wrapper adding comprehensive logging functionality to components.
Base BaseClass
Base class typedef for component functionality.
Component Configuration
<Component Id="MyComp" Class="MyComponent">
<Reference Id="Log" Value="MainLog"/>
<Reference Id="TracingConfiguration" Value="GlobalTracing"/>
<Attribute Id="EnableVerbose" Value="true"/>
<Attribute Id="ShowComponentId" Value="true"/>
</Component>
Message Source Decoration
When ShowComponentId is enabled, messages are automatically prefixed with the component ID:
// Without ShowComponentId:
"Processing started - ProcessData"
// With ShowComponentId:
"Processing started - MyComp (ProcessData)"
Type Aliases
For convenience, a typedef is provided for the common case:
// Usage:
class MyComponent : public ilog::CLoggerComponentBase
{
// ... component implementation ...
};
TLoggerCompWrap< icomp::CComponentBase > CLoggerComponentBase
Convenience typedef for simple components with logging.
See also
ilog::CLoggerBase, ilog::ITracingConfiguration, ilog::CLoggerComponentBase

Definition at line 128 of file TLoggerCompWrap.h.

Member Typedef Documentation

◆ BaseClass

template<class Base >
typedef Base ilog::TLoggerCompWrap< Base >::BaseClass

Base class typedef for component functionality.

Definition at line 134 of file TLoggerCompWrap.h.

◆ BaseClass2

template<class Base >
typedef ilog::CLoggerBase ilog::TLoggerCompWrap< Base >::BaseClass2

Base class typedef for logger functionality.

Definition at line 137 of file TLoggerCompWrap.h.

Member Function Documentation

◆ DecorateMessage()

template<class Base >
void ilog::TLoggerCompWrap< Base >::DecorateMessage ( istd::IInformationProvider::InformationCategory  category,
int  id,
int  flags,
QString &  message,
QString &  messageSource 
) const
overrideprotectedvirtual

Decorate message before sending.

Adds component ID to message source if ShowComponentId is enabled. Called automatically before messages are sent.

Override to add custom decoration:

virtual void DecorateMessage(
int id,
int flags,
QString& message,
QString& messageSource) const override
{
BaseClass::DecorateMessage(category, id, flags, message, messageSource);
// Add custom decoration
message = QString("[%1] %2").arg(GetCustomPrefix()).arg(message);
}
virtual void DecorateMessage(istd::IInformationProvider::InformationCategory category, int id, int flags, QString &message, QString &messageSource) const override
Decorate message before sending.
InformationCategory
Category of information.
Parameters
categoryMessage category
idMessage ID
flagsMessage flags
messageMessage text (can be modified)
messageSourceMessage source (can be modified)

Reimplemented from ilog::CLoggerBase.

Definition at line 304 of file TLoggerCompWrap.h.

References icomp::IComponentContext::GetContextId(), and NULL.

Referenced by ifile::TDeviceBasedSerializerComp< ReadArchive, WriteArchive >::ReadArchiveEx::SendLogMessage(), and ifile::TDeviceBasedSerializerComp< ReadArchive, WriteArchive >::WriteArchiveEx::SendLogMessage().

◆ IsVerboseEnabled()

template<class Base >
bool ilog::TLoggerCompWrap< Base >::IsVerboseEnabled ( int  tracingLevel = 0) const
protected

Check if verbose messages are enabled for a given tracing level.

Determines whether verbose messages at the specified tracing level should be output. Checks both the EnableVerbose attribute and the tracing configuration (if present).

Parameters
tracingLevelTracing level to check (0=always if enabled, higher=more selective)
Returns
true if verbose messages at this level are enabled
Example
SendVerboseMessage("Detailed diagnostic", QString(), 1);
}
bool IsVerboseEnabled(int tracingLevel=0) const
Check if verbose messages are enabled for a given tracing level.
void SendVerboseMessage(const QString &message, const QString &messageSource=QString(), int tracingLevel=0) const
Send a verbose message if enabled.
See also
SendVerboseMessage()

Definition at line 276 of file TLoggerCompWrap.h.

References istd::IInformationProvider::IC_NONE.

◆ OnComponentCreated()

template<class Base >
void ilog::TLoggerCompWrap< Base >::OnComponentCreated ( )
overrideprotectedvirtual

Called when component is created.

Automatically connects the log consumer from the "Log" reference.

Note
Override to add initialization, but always call base class:
virtual void OnComponentCreated() override {
// Custom initialization
BaseClass::OnComponentCreated();
}
virtual void OnComponentCreated() override
Called when component is created.

Reimplemented in idoc::CMultiPageDocumentFilePersistenceComp, ifile::CAutoPersistenceComp, ifile::CFileListProviderComp, ifile::CFileSerializerCompBase, ifile::CFileSystemInfoProviderComp, ifile::CGeneratedFileNameParamComp, ifilegui::CExternalOpenDocumentCommandCompBase, ifilegui::CFileDialogLoaderComp, ipackage::CPackagesLoaderComp, ipackage::CRegistriesManagerComp, iqt::CTranslationManagerComp, iqtdoc::CExternalOpenDocumentCommandComp, and iqtgui::CProcessStartCommandComp.

Definition at line 330 of file TLoggerCompWrap.h.

◆ OnComponentDestroyed()

template<class Base >
void ilog::TLoggerCompWrap< Base >::OnComponentDestroyed ( )
overrideprotectedvirtual

Called when component is destroyed.

Automatically disconnects the log consumer for cleanup.

Note
Override to add cleanup, but always call base class:
virtual void OnComponentDestroyed() override {
// Custom cleanup
BaseClass::OnComponentDestroyed();
}
virtual void OnComponentDestroyed() override
Called when component is destroyed.

Reimplemented in ibase::CConsoleApplicationComp, ifile::CAutoPersistenceComp, ifile::CFileListProviderComp, ifile::CFileSystemInfoProviderComp, ifile::CGeneratedFileNameParamComp, iqt::CTranslationManagerComp, and iqtdoc::CExternalOpenDocumentCommandComp.

Definition at line 341 of file TLoggerCompWrap.h.

References NULL.

◆ SendVerboseMessage()

template<class Base >
void ilog::TLoggerCompWrap< Base >::SendVerboseMessage ( const QString &  message,
const QString &  messageSource = QString(),
int  tracingLevel = 0 
) const
protected

Send a verbose message if enabled.

Convenience method for sending verbose/diagnostic messages. The message is only sent if IsVerboseEnabled(tracingLevel) returns true.

Verbose messages use category IC_NONE and are typically used for diagnostic output that's not always needed.

Parameters
messageMessage text
messageSourceOptional message source (default: empty)
tracingLevelTracing level (0=always if enabled, higher=more selective)
Example
// Basic verbose message
SendVerboseMessage("Operation started");
// With source
SendVerboseMessage("Processing item 5", "ProcessItems");
// With tracing level
SendVerboseMessage("Very detailed info", "Details", 2);
See also
IsVerboseEnabled()

Definition at line 293 of file TLoggerCompWrap.h.

References istd::IInformationProvider::IC_NONE.


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