Definition at line 59 of file FGLog.cpp.
|
| const char * | c_str (void) const noexcept |
| |
| void | FileLocation (const std::string &filename, int line) override |
| | Optionally provides source filename and line for contextual diagnostics.
|
| |
| 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.
|
| |
| virtual | ~FGLogger () |
| | Virtual destructor for polymorphic use.
|
| |
| virtual void | Flush (void) |
| | Ends the current log record and commits any buffered output.
|
| |
| virtual void | SetLevel (LogLevel level) |
| | Starts a new log record and provides its severity level.
|
| |
◆ BufferLogger()
Definition at line 62 of file FGLog.cpp.
62{ logMessageBuffer[0] = '\0'; }
◆ ~BufferLogger()
Definition at line 116 of file FGLog.cpp.
117{
118 if (tokens.empty()) return;
119
120 GlobalLogger->SetLevel(log_level);
121
122 if (line > 0) GlobalLogger->FileLocation(filename, line);
123
124 for (const auto& token : tokens) {
125 if (token.messageItem.empty()) {
126 GlobalLogger->Format(token.format);
127 continue;
128 }
129 GlobalLogger->Message(std::string(token.messageItem));
130 }
131 GlobalLogger->Flush();
132}
◆ c_str()
| const char * c_str |
( |
void |
| ) |
const |
|
inlinenoexcept |
Definition at line 69 of file FGLog.cpp.
69{ return logMessageBuffer; }
◆ 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 63 of file FGLog.cpp.
63 {
64 this->filename = filename;
65 this->line = line;
66 }
◆ Format()
| void Format |
( |
LogFormat |
format | ) |
|
|
overridevirtual |
Applies a formatting hint to subsequent output.
Reimplemented from FGLogger.
Definition at line 108 of file FGLog.cpp.
109{
110 auto& new_token = tokens.emplace_back();
111 new_token.format = format;
112}
◆ Message()
| void Message |
( |
const std::string & |
message | ) |
|
|
overridevirtual |
Appends message text. May be called multiple times per log record.
Implements FGLogger.
Definition at line 88 of file FGLog.cpp.
88 {
89 if (message.empty()) return;
90
91 size_t available = sizeof(logMessageBuffer) - bufferUsed - 1;
92 size_t toCopy = std::min(message.size(), available);
93
94 if (toCopy > 0) {
95
96 char* currentPos = logMessageBuffer + bufferUsed;
97 memcpy(currentPos, message.c_str(), toCopy);
98 bufferUsed += toCopy;
99 logMessageBuffer[bufferUsed] = '\0';
100
101 auto& new_token = tokens.emplace_back();
102 new_token.messageItem = std::string_view(currentPos, toCopy);
103 }
104}
The documentation for this class was generated from the following file: