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
FGLogConsole Class Reference

Detailed Description

Definition at line 202 of file FGLog.h.

+ Inheritance diagram for FGLogConsole:
+ Collaboration diagram for FGLogConsole:

Public Member Functions

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

Protected Attributes

std::string buffer
 
LogLevel min_level = LogLevel::BULK
 
- Protected Attributes inherited from FGLogger
LogLevel log_level = LogLevel::BULK
 

Constructor & Destructor Documentation

◆ ~FGLogConsole()

~FGLogConsole ( )
inlineoverride

Definition at line 211 of file FGLog.h.

211{ Flush(); }
void Flush(void) override
Ends the current log record and commits any buffered output.
Definition FGLog.cpp:181

Member Function Documentation

◆ FileLocation()

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

Optionally provides source filename and line for contextual diagnostics.

Reimplemented from FGLogger.

Definition at line 206 of file FGLog.h.

207 { buffer.append("\nIn file " + filename + ": line " + std::to_string(line) + "\n"); }

◆ Flush()

void Flush ( void  )
overridevirtual

Ends the current log record and commits any buffered output.

Reimplemented from FGLogger.

Definition at line 181 of file FGLog.cpp.

181 {
182 if (log_level >= min_level || log_level == LogLevel::STDOUT) {
183 switch (log_level)
184 {
185 case LogLevel::BULK:
186 case LogLevel::DEBUG:
187 case LogLevel::INFO:
188 case LogLevel::STDOUT:
189 std::cout << buffer;
190 std::cout.flush(); // Force the message to be immediately displayed in the console
191 break;
192 default:
193 std::cerr << buffer;
194 std::cerr.flush(); // Force the message to be immediately displayed in the console
195 break;
196 }
197 }
198
199 buffer.clear();
200}

◆ Format()

void Format ( LogFormat  format)
overridevirtual

Applies a formatting hint to subsequent output.

Reimplemented from FGLogger.

Definition at line 204 of file FGLog.cpp.

204 {
205 switch (format)
206 {
207 case LogFormat::RED:
208 buffer.append(FGJSBBase::fgred);
209 break;
210 case LogFormat::BLUE:
211 buffer.append(FGJSBBase::fgblue);
212 break;
213 case LogFormat::BOLD:
214 buffer.append(FGJSBBase::highint);
215 break;
216 case LogFormat::NORMAL:
217 buffer.append(FGJSBBase::normint);
218 break;
219 case LogFormat::UNDERLINE_ON:
220 buffer.append(FGJSBBase::underon);
221 break;
222 case LogFormat::UNDERLINE_OFF:
223 buffer.append(FGJSBBase::underoff);
224 break;
225 case LogFormat::DEFAULT:
226 buffer.append(FGJSBBase::fgdef);
227 break;
228 case LogFormat::RESET:
229 default:
230 buffer.append(FGJSBBase::reset);
231 break;
232 }
233}
static char normint[6]
normal intensity text
Definition FGJSBBase.h:155
static char fgred[6]
red text
Definition FGJSBBase.h:167
static char fgblue[6]
blue text
Definition FGJSBBase.h:163
static char underon[5]
underlines text
Definition FGJSBBase.h:159
static char fgdef[6]
default text
Definition FGJSBBase.h:171
static char reset[5]
resets text properties
Definition FGJSBBase.h:157
static char underoff[6]
underline off
Definition FGJSBBase.h:161
static char highint[5]
highlights text
Definition FGJSBBase.h:151

◆ Message()

void Message ( const std::string &  message)
inlineoverridevirtual

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

Implements FGLogger.

Definition at line 208 of file FGLog.h.

208{ buffer.append(message); }

◆ SetMinLevel()

void SetMinLevel ( LogLevel  level)
inline

Definition at line 205 of file FGLog.h.

205{ min_level = level; }

Member Data Documentation

◆ buffer

std::string buffer
protected

Definition at line 214 of file FGLog.h.

◆ min_level

LogLevel min_level = LogLevel::BULK
protected

Definition at line 215 of file FGLog.h.


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