ACF $AcfVersion:0$
Public Types | Public Member Functions | Protected Member Functions | List of all members
ilog::CStreamLogCompBase Class Referenceabstract

Base class for stream-based logging components. More...

#include <CStreamLogCompBase.h>

Inheritance diagram for ilog::CStreamLogCompBase:
ilog::CLogCompBase ilog::TMessageDelegatorComp< icomp::CComponentBase > icomp::CComponentBase ilog::IMessageConsumer icomp::IComponent istd::IPolymorphic istd::IPolymorphic ifile::CTextFileLogComp ifile::CTextFileLogStreamerComp ilog::CConsoleLogComp

Public Types

typedef ilog::CLogCompBase BaseClass
 Base class typedef.
 
- Public Types inherited from ilog::CLogCompBase
typedef ilog::TMessageDelegatorComp< icomp::CComponentBaseBaseClass
 Base class typedef for component functionality.
 
typedef QObject BaseClass2
 Base class typedef for QObject functionality.
 
- Public Types inherited from ilog::TMessageDelegatorComp< icomp::CComponentBase >
typedef icomp::CComponentBase BaseClass
 Base class typedef.
 
- Public Types inherited from ilog::IMessageConsumer
typedef istd::TSharedInterfacePtr< istd::IInformationProviderMessagePtr
 Shared pointer type for message objects.
 

Public Member Functions

 CStreamLogCompBase ()
 
istd::IInformationProvider::InformationCategory GetWorseCategory () const
 Get worse category (highest code) of all outputed messages.
 
virtual bool IsMessageSupported (int messageCategory=-1, int messageId=-1, const istd::IInformationProvider *messagePtr=NULL) const override
 Check if a message is supported.
 
- Public Member Functions inherited from ilog::CLogCompBase
 CLogCompBase ()
 Default constructor.
 
virtual void AddMessage (const MessagePtr &messagePtr) override
 Add a message to this log component.
 
- Public Member Functions inherited from icomp::CComponentBase
 CComponentBase ()
 Create component and assign it to specific context.
 
virtual const icomp::IComponentGetParentComponent (bool ownerOnly=false) const override
 Get parent of this component.
 
virtual void * GetInterface (const istd::CClassInfo &interfaceType, const QByteArray &subId="") override
 Get access to specified component interface.
 
virtual IComponentContextSharedPtr GetComponentContext () const override
 Get access to component context describing all application-specified component information loaded from components registry.
 
virtual void SetComponentContext (const IComponentContextSharedPtr &contextPtr, const icomp::IComponent *parentPtr, bool isParentOwner) override
 Set component context of this component.
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 

Protected Member Functions

virtual void WriteMessageToStream (const istd::IInformationProvider &message)
 Write formatted message to the output stream.
 
virtual QString GenerateMessageText (const istd::IInformationProvider &message) const
 Generate formatted message text for the output.
 
virtual void WriteText (const QString &text, istd::IInformationProvider::InformationCategory category)=0
 Write a text line to the output stream.
 
virtual void WriteMessageToLog (const MessagePtr &messagePtr) override
 Abstract method called to process a message.
 
virtual void OnComponentDestroyed () override
 
- Protected Member Functions inherited from icomp::CComponentBase
bool IsComponentActive () const
 Check if component is active.
 
virtual void OnComponentCreated ()
 
virtual const icomp::IRealComponentStaticInfoGetComponentStaticInfo () const =0
 Get access to static info of this component.
 

Additional Inherited Members

- Signals inherited from ilog::CLogCompBase
void EmitAddMessage (const MessagePtr &messagePtr)
 Signal emitted when a message is added.
 
- Static Protected Member Functions inherited from icomp::CComponentBase
static const icomp::IRealComponentStaticInfoInitStaticInfo (IComponent *componentPtr)
 
static QByteArray GetComponentId (const icomp::IComponentContext *componentContextPtr, const QByteArray &contextId=QByteArray())
 

Detailed Description

Base class for stream-based logging components.

CStreamLogCompBase provides foundation for logging components that output formatted messages to text streams. It handles message filtering by severity, message formatting with customizable elements (category, code, timestamp), and tracks statistics.

Derived classes implement WriteText() to output the formatted message to their specific destination (console, file, network, etc.).

Features
  • Severity level filtering (only log messages above minimum category)
  • Customizable message formatting:
    • Optional category label ("Info:", "Warning:", "Error:", "Critical:")
    • Optional message ID/code display
    • Optional timestamp with configurable format
  • Dot display for filtered messages (shows "." for suppressed messages)
  • Worst category tracking (highest severity seen)
  • Thread-safe operation via CLogCompBase
Configuration
Component attributes:
  • MinCategory: Minimum severity to log (0=all, 1=info+, 2=warning+, 3=error+, 4=critical)
  • ShowDots: Show dot (".") for each filtered message (default: false)
  • UseCategory: Include category label in output (default: true)
  • UseCode: Include message ID in output (default: true)
  • UseTimeStamp: Include timestamp in output (default: false)
  • TimeFormat: Qt date/time format string (default: "dd.MM hh:mm:ss:zzz")
Message Format
Typical output format (depending on configuration):
[12:34:56.789] Warning (2001): Low disk space - DiskMonitor
Error (5001): Connection failed - NetworkManager
Info: Application started - Main
Usage Example (Derived Class)
class CFileLogComp : public ilog::CStreamLogCompBase
{
public:
CFileLogComp() : m_file("log.txt") {
m_file.open(QIODevice::WriteOnly | QIODevice::Text);
}
protected:
virtual void WriteText(const QString& text,
if (m_file.isOpen()) {
m_file.write(text.toUtf8());
m_file.flush();
}
}
private:
QFile m_file;
};
Base class for stream-based logging components.
InformationCategory
Category of information.
See also
ilog::CConsoleLogComp, ilog::CLogCompBase

Definition at line 77 of file CStreamLogCompBase.h.

Member Typedef Documentation

◆ BaseClass

Base class typedef.

Definition at line 81 of file CStreamLogCompBase.h.

Constructor & Destructor Documentation

◆ CStreamLogCompBase()

ilog::CStreamLogCompBase::CStreamLogCompBase ( )

Member Function Documentation

◆ GenerateMessageText()

virtual QString ilog::CStreamLogCompBase::GenerateMessageText ( const istd::IInformationProvider message) const
protectedvirtual

Generate formatted message text for the output.

◆ GetWorseCategory()

istd::IInformationProvider::InformationCategory ilog::CStreamLogCompBase::GetWorseCategory ( ) const

Get worse category (highest code) of all outputed messages.

◆ IsMessageSupported()

virtual bool ilog::CStreamLogCompBase::IsMessageSupported ( int  messageCategory = -1,
int  messageId = -1,
const istd::IInformationProvider messagePtr = NULL 
) const
overridevirtual

Check if a message is supported.

Delegates the check to the slave consumer if present. If no slave is configured, returns true (accepts all messages).

Parameters
messageCategoryMessage category to check (or -1)
messageIdMessage ID to check (or -1)
messagePtrComplete message to check (or NULL)
Returns
true if message is supported by slave (or if no slave)

Reimplemented from ilog::TMessageDelegatorComp< icomp::CComponentBase >.

◆ OnComponentDestroyed()

virtual void ilog::CStreamLogCompBase::OnComponentDestroyed ( )
overrideprotectedvirtual

◆ WriteMessageToLog()

virtual void ilog::CStreamLogCompBase::WriteMessageToLog ( const MessagePtr messagePtr)
overrideprotectedvirtual

Abstract method called to process a message.

Derived classes must implement this to define message handling behavior. This is always called on the component's thread, regardless of which thread called AddMessage().

Parameters
messagePtrShared pointer to message to process
Example
virtual void WriteMessageToLog(const MessagePtr& messagePtr) override {
// Store in container
m_messages.append(messagePtr);
// Update UI
UpdateDisplay();
// Forward to slave
if (m_slave) m_slave->AddMessage(messagePtr);
}
virtual void WriteMessageToLog(const MessagePtr &messagePtr) override
Abstract method called to process a message.
Shared ownership smart pointer for interface types.

Implements ilog::CLogCompBase.

◆ WriteMessageToStream()

virtual void ilog::CStreamLogCompBase::WriteMessageToStream ( const istd::IInformationProvider message)
protectedvirtual

Write formatted message to the output stream.

◆ WriteText()

virtual void ilog::CStreamLogCompBase::WriteText ( const QString &  text,
istd::IInformationProvider::InformationCategory  category 
)
protectedpure virtual

Write a text line to the output stream.

Implemented in ifile::CTextFileLogComp, ifile::CTextFileLogStreamerComp, and ilog::CConsoleLogComp.


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