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

Console logging component with colored output. More...

#include <CConsoleLogComp.h>

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

Public Types

typedef CStreamLogCompBase BaseClass
 
- Public Types inherited from ilog::CStreamLogCompBase
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.
 

Protected Member Functions

virtual void WriteText (const QString &text, istd::IInformationProvider::InformationCategory category) override
 Write a text line to the output stream.
 
- Protected Member Functions inherited from ilog::CStreamLogCompBase
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 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.
 
- Public Member Functions inherited from ilog::CStreamLogCompBase
 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 ()
 
- 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

Console logging component with colored output.

CConsoleLogComp outputs log messages to the console (std::wcout) with platform-specific colored output based on message severity. This makes it easy to visually distinguish between info, warnings, and errors when running applications from the command line.

The component uses CStreamLogCompBase for message formatting and filtering, and adds color support for both Windows (via Windows console API) and Unix-like systems (via ANSI escape codes).

Color Scheme
  • Info/None: Default console color (typically white/gray)
  • Warning: Yellow/amber text
  • Error: Red text
  • Critical: Bright red text
Platform Support
  • Windows: Uses SetConsoleTextAttribute API
  • Unix/Linux/macOS: Uses ANSI escape codes (when terminal supports them)
Usage Example
// Create console logger
// Configure formatting
// In .acc:
// MinCategory: 1 (info and above)
// UseCategory: true (show "Warning:", "Error:")
// UseCode: true (show message IDs)
// UseTimeStamp: false (no timestamps)
// Send messages
1001, "Application started", "Main")));
5001, "Connection failed", "Network")));
// Console output:
// Info (1001): Application started - Main
// Error (5001): Connection failed - Network [in red]
Console logging component with colored output.
Basic implementation of the istd::IInformationProvider interface for log messages.
Definition CMessage.h:80
@ IC_ERROR
Information about error, processing could not be done correctly.
@ IC_INFO
Normal information level.
Shared ownership smart pointer for interface types.
Component Configuration
<Component Id="ConsoleLog" Class="ilog::CConsoleLogComp">
<Attribute Id="MinCategory" Value="1"/>
<Attribute Id="UseCategory" Value="true"/>
<Attribute Id="UseCode" Value="true"/>
<Attribute Id="UseTimeStamp" Value="true"/>
<Attribute Id="TimeFormat" Value="hh:mm:ss"/>
</Component>
Note
Color support depends on terminal capabilities. Some terminals or redirected output may not display colors correctly.
See also
ilog::CStreamLogCompBase, ilog::CLogCompBase

Definition at line 81 of file CConsoleLogComp.h.

Member Typedef Documentation

◆ BaseClass

Definition at line 84 of file CConsoleLogComp.h.

Member Function Documentation

◆ WriteText()

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

Write a text line to the output stream.

Implements ilog::CStreamLogCompBase.


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