FGLogger

class jsbsim.FGLogger

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.

file_location(filename: str, line: int) None

Optionally provides source filename and line for contextual diagnostics.

flush() None

Ends the current log record and commits any buffered output.

format(format: LogFormat) None

Applies a formatting hint to subsequent output.

message(message: str) None

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

set_level(level: LogLevel) None

Starts a new log record and provides its severity level.

class jsbsim.DefaultLogger

Default logger: print messages to stdout without formatting.

file_location(filename: str, line: int) None

Optionally provides source filename and line for contextual diagnostics.

message(message: str) None

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

jsbsim.set_logger(logger: FGLogger) None

Sets the active logger for the current thread.

The logger is stored in thread-local storage: all JSBSim instances running in this thread share this same FGLogger instance, while other threads keep their own independent logger instance.

jsbsim.get_logger() FGLogger

Returns the active logger for the current thread.