JSBSim Flight Dynamics Model 1.3.3 (16 Oct 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 DisableHighLighting (void)
 
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
 
bool highlighting = true
 
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:192

Member Function Documentation

◆ DisableHighLighting()

void DisableHighLighting ( void  )
inline

Definition at line 212 of file FGLog.h.

212{ highlighting = false; }

◆ 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 192 of file FGLog.cpp.

192 {
193 if (log_level >= min_level || log_level == LogLevel::STDOUT) {
194 switch (log_level)
195 {
196 case LogLevel::BULK:
197 case LogLevel::DEBUG:
198 case LogLevel::INFO:
199 case LogLevel::STDOUT:
200 std::cout << buffer;
201 std::cout.flush(); // Force the message to be immediately displayed in the console
202 break;
203 default:
204 std::cerr << buffer;
205 std::cerr.flush(); // Force the message to be immediately displayed in the console
206 break;
207 }
208 }
209
210 buffer.clear();
211}

◆ Format()

void Format ( LogFormat  format)
overridevirtual

Applies a formatting hint to subsequent output.

Reimplemented from FGLogger.

Definition at line 215 of file FGLog.cpp.

215 {
216 if (!highlighting) return;
217
218 switch (format)
219 {
220 case LogFormat::RED:
221 buffer.append(fgred);
222 break;
223 case LogFormat::BLUE:
224 buffer.append(fgblue);
225 break;
226 case LogFormat::GREEN:
227 buffer.append(fggreen);
228 break;
229 case LogFormat::CYAN:
230 buffer.append(fgcyan);
231 break;
232 case LogFormat::BOLD:
233 buffer.append(highint);
234 break;
235 case LogFormat::NORMAL:
236 buffer.append(normint);
237 break;
238 case LogFormat::UNDERLINE_ON:
239 buffer.append(underon);
240 break;
241 case LogFormat::UNDERLINE_OFF:
242 buffer.append(underoff);
243 break;
244 case LogFormat::DEFAULT:
245 buffer.append(fgdef);
246 break;
247 case LogFormat::RESET:
248 default:
249 buffer.append(reset);
250 break;
251 }
252}

◆ 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 216 of file FGLog.h.

◆ highlighting

bool highlighting = true
protected

Definition at line 215 of file FGLog.h.

◆ min_level

LogLevel min_level = LogLevel::BULK
protected

Definition at line 217 of file FGLog.h.


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