A class to manage raw binary log files. More...
#include <logFileRaw.hpp>

Public Member Functions | |
| logFileRaw () | |
| Default constructor. | |
| ~logFileRaw () | |
| Destructor. | |
| mx::error_t | logPath (const std::string &newPath) |
| Set the path. | |
| std::string | logPath () |
| Get the path. | |
| mx::error_t | logName (const std::string &newName) |
| Set the log name. | |
| std::string | logName () |
| Get the name. | |
| mx::error_t | logExt (const std::string &newExt) |
| Set the log extension. | |
| std::string | logExt () |
| Get the log extension. | |
| mx::error_t | maxLogSize (size_t newMaxFileSize) |
| Set the maximum file size. | |
| size_t | maxLogSize () |
| Get the maximum file size. | |
| mx::error_t | writeLog (flatlogs::bufferPtrT &data) |
| Write a log entry to the file. | |
| mx::error_t | flush () |
| Flush the stream. | |
| mx::error_t | close () |
| Close the file pointer. | |
Protected Member Functions | |
| mx::error_t | createFile (flatlogs::timespecX &ts) |
| Create a new file. | |
Protected Attributes | |
Configurable Parameters | |
| std::string | m_logPath { "." } |
| The base path for the log files. | |
| std::string | m_logName { "xlog" } |
| The base name for the log files. | |
| std::string | m_logExt { MAGAOX_default_logExt } |
| The extension for the log files. | |
| size_t | m_maxLogSize { MAGAOX_default_max_logSize } |
| The maximum file size in bytes. Default is 10 MB. | |
Internal State | |
| FILE * | m_fout { 0 } |
| The file pointer. | |
| size_t | m_currFileSize { 0 } |
| The current file size. | |
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]/[name]_YYYYMMDDHHMMSSNNNNNNNNN.[ext] where fields in [] are configurable.
The timestamp in the file name is from the first entry of the file.
Definition at line 36 of file logFileRaw.hpp.
| MagAOX::logger::logFileRaw< verboseT >::logFileRaw | ( | ) |
| MagAOX::logger::logFileRaw< verboseT >::~logFileRaw | ( | ) |
| mx::error_t MagAOX::logger::logFileRaw< verboseT >::close | ( | ) |
Close the file pointer.
Sets m_fout to nullptr after calling fclose regardless of error.
Definition at line 316 of file logFileRaw.hpp.
Referenced by libXWCTest::loggerTest::logFileRawTest::TEST_CASE().
|
protected |
Create a new file.
Closes the current file if open. Then creates a new file with a name of the form [path]/[name]/YYYY_MM_DD/[name]_YYYYMMDDHHMMSSNNNNNNNNN.[ext]
| [in] | ts | A MagAOX timespec, used to set the timestamp |
Definition at line 336 of file logFileRaw.hpp.
References MagAOX::file::fileTimeRelPath(), flatlogs::timespecX::time_ns, and flatlogs::timespecX::time_s.
| mx::error_t MagAOX::logger::logFileRaw< verboseT >::flush | ( | ) |
Flush the stream.
Calls fflush. See issue #192
Definition at line 301 of file logFileRaw.hpp.
| std::string MagAOX::logger::logFileRaw< verboseT >::logExt | ( | ) |
Get the log extension.
Definition at line 245 of file logFileRaw.hpp.
| mx::error_t MagAOX::logger::logFileRaw< verboseT >::logExt | ( | const std::string & | newExt | ) |
Set the log extension.
| [in] | newExt | the new value of m_logExt |
Definition at line 226 of file logFileRaw.hpp.
Referenced by libXWCTest::loggerTest::logFileRawTest::TEST_CASE(), libXWCTest::loggerTest::logFileRawTest::TEST_CASE(), and libXWCTest::loggerTest::logFileRawTest::TEST_CASE().
| std::string MagAOX::logger::logFileRaw< verboseT >::logName | ( | ) |
| mx::error_t MagAOX::logger::logFileRaw< verboseT >::logName | ( | const std::string & | newName | ) |
Set the log name.
| [in] | newName | the new value of m_logName |
Definition at line 201 of file logFileRaw.hpp.
Referenced by libXWCTest::loggerTest::logFileRawTest::TEST_CASE(), libXWCTest::loggerTest::logFileRawTest::TEST_CASE(), and libXWCTest::loggerTest::logFileRawTest::TEST_CASE().
| std::string MagAOX::logger::logFileRaw< verboseT >::logPath | ( | ) |
| mx::error_t MagAOX::logger::logFileRaw< verboseT >::logPath | ( | const std::string & | newPath | ) |
Set the path.
| [in] | newPath | the new value of _path |
Definition at line 176 of file logFileRaw.hpp.
Referenced by libXWCTest::loggerTest::logFileRawTest::TEST_CASE().
| size_t MagAOX::logger::logFileRaw< verboseT >::maxLogSize | ( | ) |
Get the maximum file size.
Definition at line 270 of file logFileRaw.hpp.
| mx::error_t MagAOX::logger::logFileRaw< verboseT >::maxLogSize | ( | size_t | newMaxFileSize | ) |
Set the maximum file size.
| [in] | newMaxFileSize | the new value of _maxLogSize |
Definition at line 251 of file logFileRaw.hpp.
Referenced by libXWCTest::loggerTest::logFileRawTest::TEST_CASE(), and libXWCTest::loggerTest::logFileRawTest::TEST_CASE().
| mx::error_t MagAOX::logger::logFileRaw< verboseT >::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 276 of file logFileRaw.hpp.
References flatlogs::logHeader::timespec(), and flatlogs::logHeader::totalSize().
Referenced by libXWCTest::loggerTest::logFileRawTest::TEST_CASE().
|
protected |
The current file size.
Definition at line 56 of file logFileRaw.hpp.
|
protected |
The file pointer.
Definition at line 54 of file logFileRaw.hpp.
|
protected |
The extension for the log files.
Definition at line 45 of file logFileRaw.hpp.
|
protected |
The base name for the log files.
Definition at line 44 of file logFileRaw.hpp.
|
protected |
The base path for the log files.
Definition at line 43 of file logFileRaw.hpp.
|
protected |
The maximum file size in bytes. Default is 10 MB.
Definition at line 47 of file logFileRaw.hpp.