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 86 of file Log.h.
◆ File()
| ripple::Logs::File::File |
( |
| ) |
|
Construct with no associated system file.
A system file may be associated later with open.
- See also
- open
Definition at line 68 of file Log.cpp.
◆ ~File()
| ripple::Logs::File::~File |
( |
| ) |
|
|
default |
Destroy the object.
If a system file is associated, it will be flushed and closed.
◆ isOpen()
| bool ripple::Logs::File::isOpen |
( |
| ) |
const |
|
noexcept |
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 73 of file Log.cpp.
◆ open()
| bool ripple::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 79 of file Log.cpp.
◆ closeAndReopen()
| bool ripple::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 102 of file Log.cpp.
◆ close()
| void ripple::Logs::File::close |
( |
| ) |
|
Close the system file if it is open.
Definition at line 110 of file Log.cpp.
◆ write() [1/2]
| void ripple::Logs::File::write |
( |
char const * |
text | ) |
|
write to the log file.
Does nothing if there is no associated system file.
Definition at line 116 of file Log.cpp.
◆ writeln() [1/2]
| void ripple::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 123 of file Log.cpp.
◆ write() [2/2]
| void ripple::Logs::File::write |
( |
std::string const & |
str | ) |
|
◆ writeln() [2/2]
| void ripple::Logs::File::writeln |
( |
std::string const & |
str | ) |
|
◆ m_stream
◆ m_path
| boost::filesystem::path ripple::Logs::File::m_path |
|
private |