The log
class provides basic file-based logging functionality.
More...
#include <logging_impl.hpp>
|
| log (const std::filesystem::path &log_path) |
| Constructs a log object that manages logging to a file.
|
|
| ~log () noexcept |
| Destructor writes a final footer line before the log object is destroyed.
|
|
void | append (const std::wstring &str) noexcept |
| Appends a wide-string message to the log, along with thread and timestamp information.
|
|
void | append (const std::string &str) noexcept |
| Appends a narrow-string message to the log (converted internally to wide-string).
|
|
The log
class provides basic file-based logging functionality.
It creates or overwrites a log file at a specified path, writes log entries with timestamps and thread information, and ensures thread safety via a mutex.
◆ log()
cbeam::logging::log::log |
( |
const std::filesystem::path & | log_path | ) |
|
|
inlineexplicit |
Constructs a log object that manages logging to a file.
The constructor attempts to create parent directories, remove any existing log file, and then writes an initial header line.
- Parameters
-
log_path | The filesystem path to the log file. |
◆ ~log()
cbeam::logging::log::~log |
( |
| ) |
|
|
inlinenoexcept |
Destructor writes a final footer line before the log object is destroyed.
Also locks the mutex to ensure no other threads are writing at the same time.
◆ append() [1/2]
void cbeam::logging::log::append |
( |
const std::string & | str | ) |
|
|
inlinenoexcept |
Appends a narrow-string message to the log (converted internally to wide-string).
- Parameters
-
str | The narrow string message to be logged. |
◆ append() [2/2]
void cbeam::logging::log::append |
( |
const std::wstring & | str | ) |
|
|
inlinenoexcept |
Appends a wide-string message to the log, along with thread and timestamp information.
This method attempts a non-blocking lock first for performance, falling back to a blocking lock if needed.
- Parameters
-
str | The wide string message to be logged. |
The documentation for this class was generated from the following file: