A class to manage raw binary log files. More...
#include <logFileRaw.hpp>
Public Member Functions | |
logFileRaw () | |
Default constructor. More... | |
~logFileRaw () | |
Destructor. More... | |
int | logPath (const std::string &newPath) |
Set the path. More... | |
std::string | logPath () |
Get the path. More... | |
int | logName (const std::string &newName) |
Set the log name. More... | |
std::string | logName () |
Get the name. More... | |
int | logExt (const std::string &newExt) |
Set the log extension. More... | |
std::string | logExt () |
Get the log extension. More... | |
int | maxLogSize (size_t newMaxFileSize) |
Set the maximum file size. More... | |
size_t | maxLogSize () |
Get the maximum file size. More... | |
int | writeLog (flatlogs::bufferPtrT &data) |
Write a log entry to the file. More... | |
int | flush () |
Flush the stream. More... | |
int | close () |
Close the file pointer. More... | |
Protected Member Functions | |
int | createFile (flatlogs::timespecX &ts) |
Create a new file. More... | |
Protected Attributes | |
Configurable Parameters | |
std::string | m_logPath {"."} |
The base path for the log files. More... | |
std::string | m_logName {"xlog"} |
The base name for the log files. More... | |
std::string | m_logExt {MAGAOX_default_logExt} |
The extension for the log files. More... | |
size_t | m_maxLogSize {MAGAOX_default_max_logSize} |
The maximum file size in bytes. Default is 10 MB. More... | |
Internal State | |
FILE * | m_fout {0} |
The file pointer. More... | |
size_t | m_currFileSize {0} |
The current file size. More... | |
A class to manage raw binary log files.
Manages a binary file containing MagAO-X logs.
The log entries are written as a binary stream of a configurable maximum size. If this size will be exceed by the next entry, then a new file is created.
Filenames have a standard form of: [path]/[name]_YYYYMMDDHHMMSSNNNNNNNNN.[ext] where fields in [] are configurable.
The timestamp is from the first entry of the file.
Definition at line 41 of file logFileRaw.hpp.
MagAOX::logger::logFileRaw::logFileRaw | ( | ) |
MagAOX::logger::logFileRaw::~logFileRaw | ( | ) |
int MagAOX::logger::logFileRaw::close | ( | ) |
Close the file pointer.
Definition at line 103 of file logFileRaw.cpp.
Referenced by ~logFileRaw().
|
protected |
Create a new file.
Closes the current file if open. Then creates a new file with a name of the form [path]/[name]_YYYYMMDDHHMMSSNNNNNNNNN.[ext]
[in] | ts | A MagAOX timespec, used to set the timestamp |
Definition at line 110 of file logFileRaw.cpp.
Referenced by writeLog().
int MagAOX::logger::logFileRaw::flush | ( | ) |
Flush the stream.
Definition at line 95 of file logFileRaw.cpp.
std::string MagAOX::logger::logFileRaw::logExt | ( | ) |
Get the log extension.
Definition at line 54 of file logFileRaw.cpp.
int MagAOX::logger::logFileRaw::logExt | ( | const std::string & | newExt | ) |
Set the log extension.
[in] | newExt | the new value of m_logExt |
Definition at line 48 of file logFileRaw.cpp.
std::string MagAOX::logger::logFileRaw::logName | ( | ) |
int MagAOX::logger::logFileRaw::logName | ( | const std::string & | newName | ) |
Set the log name.
[in] | newName | the new value of m_logName |
Definition at line 37 of file logFileRaw.cpp.
std::string MagAOX::logger::logFileRaw::logPath | ( | ) |
int MagAOX::logger::logFileRaw::logPath | ( | const std::string & | newPath | ) |
Set the path.
[in] | newPath | the new value of _path |
Definition at line 26 of file logFileRaw.cpp.
size_t MagAOX::logger::logFileRaw::maxLogSize | ( | ) |
Get the maximum file size.
Definition at line 65 of file logFileRaw.cpp.
int MagAOX::logger::logFileRaw::maxLogSize | ( | size_t | newMaxFileSize | ) |
Set the maximum file size.
[in] | newMaxFileSize | the new value of _maxLogSize |
Definition at line 59 of file logFileRaw.cpp.
int MagAOX::logger::logFileRaw::writeLog | ( | flatlogs::bufferPtrT & | data | ) |
Write a log entry to the file.
Checks if this write will exceed m_maxLogSize, and if so opens a new file. The new file will have the timestamp of this log entry.
[in] | data | the log entry to write to disk |
Definition at line 70 of file logFileRaw.cpp.
|
protected |
The current file size.
Definition at line 62 of file logFileRaw.hpp.
Referenced by createFile(), and writeLog().
|
protected |
The file pointer.
Definition at line 60 of file logFileRaw.hpp.
Referenced by close(), createFile(), flush(), and writeLog().
|
protected |
The extension for the log files.
Definition at line 51 of file logFileRaw.hpp.
Referenced by createFile(), and logExt().
|
protected |
The base name for the log files.
Definition at line 50 of file logFileRaw.hpp.
Referenced by createFile(), and logName().
|
protected |
The base path for the log files.
Definition at line 49 of file logFileRaw.hpp.
Referenced by createFile(), and logPath().
|
protected |
The maximum file size in bytes. Default is 10 MB.
Definition at line 53 of file logFileRaw.hpp.
Referenced by maxLogSize(), and writeLog().