Definition at line 70 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 73 of file FGLog.cpp.
73{ logMessageBuffer[0] = '\0'; }
◆ ~BufferLogger()
Definition at line 127 of file FGLog.cpp.
128{
129 if (tokens.empty()) return;
130
131 GlobalLogger->SetLevel(log_level);
132
133 if (line > 0) GlobalLogger->FileLocation(filename, line);
134
135 for (const auto& token : tokens) {
136 if (token.messageItem.empty()) {
137 GlobalLogger->Format(token.format);
138 continue;
139 }
140 GlobalLogger->Message(std::string(token.messageItem));
141 }
142 GlobalLogger->Flush();
143}
◆ c_str()
| const char * c_str |
( |
void |
| ) |
const |
|
inlinenoexcept |
Definition at line 80 of file FGLog.cpp.
80{ 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 74 of file FGLog.cpp.
74 {
75 this->filename = filename;
76 this->line = line;
77 }
◆ Format()
| void Format |
( |
LogFormat |
format | ) |
|
|
overridevirtual |
Applies a formatting hint to subsequent output.
Reimplemented from FGLogger.
Definition at line 119 of file FGLog.cpp.
120{
121 auto& new_token = tokens.emplace_back();
122 new_token.format = format;
123}
◆ Message()
| void Message |
( |
const std::string & |
message | ) |
|
|
overridevirtual |
Appends message text. May be called multiple times per log record.
Implements FGLogger.
Definition at line 99 of file FGLog.cpp.
99 {
100 if (message.empty()) return;
101
102 size_t available = sizeof(logMessageBuffer) - bufferUsed - 1;
103 size_t toCopy = std::min(message.size(), available);
104
105 if (toCopy > 0) {
106
107 char* currentPos = logMessageBuffer + bufferUsed;
108 memcpy(currentPos, message.c_str(), toCopy);
109 bufferUsed += toCopy;
110 logMessageBuffer[bufferUsed] = '\0';
111
112 auto& new_token = tokens.emplace_back();
113 new_token.messageItem = std::string_view(currentPos, toCopy);
114 }
115}
The documentation for this class was generated from the following file: