mirror of
https://github.com/nasa/fprime.git
synced 2025-12-11 04:35:25 -06:00
* NATIVE_INT_TYPE use in toString * NATIVE_INT_TYPE use in SimpleObjRegistry * NATIVE_INT_TYPE use in Asserts * NATIVE_INT_TYPE use in Fw/Comp * NATIVE_INT_TYPE use in getCapacity * NATIVE_INT_TYPE use in getEntries * NATIVE_INT_TYPE use in size/length * NATIVE_INT_TYPE use in FILE_NAME_ARG * NATIVE_INT_TYPE use in Fw (misc) * NATIVE_INT_TYPE use in identifier * NATIVE_INT_TYPE use in Fw (misc II) * POINTER_CAST in Buffer * POINTER_CAST in Serializable * sp * Removing no longer used DefaultTypes.hpp * Fixes to accomidate Fw refactor * Unit-test and CI fixes * Fixing review comments - pt 1
75 lines
2.3 KiB
C++
75 lines
2.3 KiB
C++
// \copyright
|
|
// Copyright 2009-2015, by the California Institute of Technology.
|
|
// ALL RIGHTS RESERVED. United States Government Sponsorship
|
|
// acknowledged.
|
|
|
|
#ifndef SVCLOGFILE_HPP_
|
|
#define SVCLOGFILE_HPP_
|
|
|
|
#include <Fw/Types/FileNameString.hpp>
|
|
#include <Os/File.hpp>
|
|
#include <Os/FileSystem.hpp>
|
|
|
|
|
|
namespace Svc {
|
|
|
|
//! \class LogFile
|
|
//! \brief LogFile struct
|
|
//!
|
|
//! The object is used for writing to a log file. Making it a struct so all
|
|
//! members are public, for ease of use in object composition.
|
|
|
|
struct LogFile {
|
|
|
|
//! \brief Constructor
|
|
//!
|
|
LogFile();
|
|
|
|
//! \brief Destructor
|
|
//!
|
|
~LogFile();
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Member Functions
|
|
// ----------------------------------------------------------------------
|
|
|
|
//! \brief Set log file and max size
|
|
//!
|
|
//! \param fileName The name of the file to create. Must be less than 80 characters.
|
|
//! \param maxSize The max size of the file
|
|
//! \param maxBackups The max backups for the file. Default: 10
|
|
//!
|
|
//! \return true if creating the file was successful, false otherwise
|
|
bool set_log_file(const char* fileName, const FwSizeType maxSize, const FwSizeType maxBackups = 10);
|
|
|
|
//! \brief Write the passed buf to the log if possible
|
|
//!
|
|
//! \param buf The buffer of data to write
|
|
//! \param size The size of buf
|
|
//!
|
|
//! \return true if writing to the file was successful, false otherwise
|
|
bool write_to_log(const char *const buf, const FwSizeType size);
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Member Variables
|
|
// ----------------------------------------------------------------------
|
|
|
|
// The name of the file to text logs to:
|
|
Fw::FileNameString m_fileName;
|
|
|
|
// The file to write text logs to:
|
|
Os::File m_file;
|
|
|
|
// The max size of the text log file:
|
|
FwSizeType m_maxFileSize;
|
|
|
|
// True if there is currently an open file to write text logs to:
|
|
bool m_openFile;
|
|
|
|
// Current size of the file:
|
|
FwSizeType m_currentFileSize;
|
|
};
|
|
|
|
}
|
|
#endif /* SVCLOGFILEL_HPP_ */
|