Manages a system file containing logged output.
More...
|
| | File () |
| | Construct with no associated system file.
|
| | ~File ()=default |
| | Destroy the object.
|
| bool | isOpen () const noexcept |
| | Determine if a system file is associated with the log.
|
| bool | open (boost::filesystem::path const &path) |
| | Associate a system file with the log.
|
| bool | closeAndReopen () |
| | Close and re-open the system file associated with the log This assists in interoperating with external log management tools.
|
| void | close () |
| | Close the system file if it is open.
|
| void | write (char const *text) |
| | write to the log file.
|
| void | writeln (char const *text) |
| | write to the log file and append an end of line marker.
|
| void | write (std::string const &str) |
| | Write to the log file using std::string.
|
| void | writeln (std::string const &str) |
Manages a system file containing logged output.
The system file remains open during program execution. Interfaces are provided for interoperating with standard log management tools like logrotate(8): http://linuxcommand.org/man_pages/logrotate8.html
- Note
- None of the listed interfaces are thread-safe.
Definition at line 49 of file Log.h.
◆ File()
| xrpl::Logs::File::File |
( |
| ) |
|
Construct with no associated system file.
A system file may be associated later with open.
- See also
- open
Definition at line 46 of file Log.cpp.
◆ ~File()
| xrpl::Logs::File::~File |
( |
| ) |
|
|
default |
Destroy the object.
If a system file is associated, it will be flushed and closed.
◆ isOpen()
| bool xrpl::Logs::File::isOpen |
( |
| ) |
const |
|
nodiscardnoexcept |
Determine if a system file is associated with the log.
- Returns
- true if a system file is associated and opened for writing.
Definition at line 51 of file Log.cpp.
◆ open()
| bool xrpl::Logs::File::open |
( |
boost::filesystem::path const & | path | ) |
|
Associate a system file with the log.
If the file does not exist an attempt is made to create it and open it for writing. If the file already exists an attempt is made to open it for appending. If a system file is already associated with the log, it is closed first.
- Returns
- true if the file was opened.
Definition at line 57 of file Log.cpp.
◆ closeAndReopen()
| bool xrpl::Logs::File::closeAndReopen |
( |
| ) |
|
Close and re-open the system file associated with the log This assists in interoperating with external log management tools.
- Returns
- true if the file was opened.
Definition at line 80 of file Log.cpp.
◆ close()
| void xrpl::Logs::File::close |
( |
| ) |
|
Close the system file if it is open.
Definition at line 88 of file Log.cpp.
◆ write() [1/2]
| void xrpl::Logs::File::write |
( |
char const * | text | ) |
|
write to the log file.
Does nothing if there is no associated system file.
Definition at line 94 of file Log.cpp.
◆ writeln() [1/2]
| void xrpl::Logs::File::writeln |
( |
char const * | text | ) |
|
write to the log file and append an end of line marker.
Does nothing if there is no associated system file.
Definition at line 101 of file Log.cpp.
◆ write() [2/2]
| void xrpl::Logs::File::write |
( |
std::string const & | str | ) |
|
◆ writeln() [2/2]
| void xrpl::Logs::File::writeln |
( |
std::string const & | str | ) |
|
◆ stream_
◆ path_
| boost::filesystem::path xrpl::Logs::File::path_ |
|
private |