JSBSim Flight Dynamics Model 1.3.0 (09 Apr 2026)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
FGLogger Class Referenceabstract

Detailed Description

Logging backend interface.

JSBSim routes each log record to an FGLogger instance instead of writing directly to stdout/stderr. Applications can keep the default FGLogConsole backend, or provide their own subclass and register it through SetLogger(FGLogger_ptr).

A single log record follows this lifecycle:

  1. SetLevel() starts a new log record and gives the severity.
  2. FileLocation() may be called (typically for XML-related messages), immediately after SetLevel() and before message content.
  3. Message() receives the textual payload. It can be invoked multiple times for one logical record because JSBSim may build a message in fragments.
  4. Format() communicates formatting intent (colors, emphasis, reset) for the subsequent output. Implementations may ignore it if formatting is not applicable.
  5. Flush() ends the current log record and is the right place to finalize and emit the record (for example: prefixing, buffering, forwarding to a UI, or forcing output synchronization).

Implementations are expected to keep enough internal state between these callbacks to assemble one coherent log record.

See also
SetLogger
GetLogger

Definition at line 124 of file FGLog.h.

#include <FGLog.h>

+ Inheritance diagram for FGLogger:

Public Member Functions

virtual ~FGLogger ()
 Virtual destructor for polymorphic use.
 
virtual void FileLocation (const std::string &filename, int line)
 Optionally provides source filename and line for contextual diagnostics.
 
virtual void Flush (void)
 Ends the current log record and commits any buffered output.
 
virtual void Format (LogFormat format)
 Applies a formatting hint to subsequent output.
 
virtual void Message (const std::string &message)=0
 Appends message text. May be called multiple times per log record.
 
virtual void SetLevel (LogLevel level)
 Starts a new log record and provides its severity level.
 

Protected Attributes

LogLevel log_level = LogLevel::BULK
 

Constructor & Destructor Documentation

◆ ~FGLogger()

virtual ~FGLogger ( )
inlinevirtual

Virtual destructor for polymorphic use.

Definition at line 128 of file FGLog.h.

128{}

Member Function Documentation

◆ FileLocation()

virtual void FileLocation ( const std::string &  filename,
int  line 
)
inlinevirtual

Optionally provides source filename and line for contextual diagnostics.

Reimplemented in BufferLogger, and FGLogConsole.

Definition at line 132 of file FGLog.h.

132{}

◆ Flush()

virtual void Flush ( void  )
inlinevirtual

Ends the current log record and commits any buffered output.

Reimplemented in FGLogConsole.

Definition at line 138 of file FGLog.h.

138{}

◆ Format()

virtual void Format ( LogFormat  format)
inlinevirtual

Applies a formatting hint to subsequent output.

Reimplemented in BufferLogger, and FGLogConsole.

Definition at line 136 of file FGLog.h.

136{}

◆ Message()

virtual void Message ( const std::string &  message)
pure virtual

Appends message text. May be called multiple times per log record.

Implemented in BufferLogger, and FGLogConsole.

◆ SetLevel()

virtual void SetLevel ( LogLevel  level)
inlinevirtual

Starts a new log record and provides its severity level.

Definition at line 130 of file FGLog.h.

130{ log_level = level;}

Member Data Documentation

◆ log_level

LogLevel log_level = LogLevel::BULK
protected

Definition at line 140 of file FGLog.h.


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