Dobby 3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
FileSink Class Reference
Inheritance diagram for FileSink:
Inheritance graph
[legend]
Collaboration diagram for FileSink:
Collaboration graph
[legend]

Public Member Functions

 FileSink (const std::string &containerId, std::shared_ptr< rt_dobby_schema > &containerConfig)
 A logging sink that sends the contents of the container stdout/err to a given file. The file can have a size limit set.
 
void DumpLog (const int bufferFd) override
 Reads all the available data from the provided fd and writes it to the output file. Does not attempt to seek the file descriptor back to the start.
 
void process (const std::shared_ptr< AICommon::IPollLoop > &pollLoop, epoll_event event) override
 Called by the pollLoop when an event occurs on the container ptty.
 

Private Member Functions

int openFile (const std::string &pathName)
 Opens the log file at a given path. Will create a new file when called, and subsequent writes will append to the file.
 

Private Attributes

const std::shared_ptr< rt_dobby_schema > mContainerConfig
 
const std::string mContainerId
 
ssize_t mFileSizeLimit
 
std::string mOutputFilePath
 
int mOutputFileFd
 
int mDevNullFd
 
bool mLimitHit
 
char mBuf [PTY_BUFFER_SIZE]
 
std::mutex mLock
 

Constructor & Destructor Documentation

◆ FileSink()

FileSink::FileSink ( const std::string &  containerId,
std::shared_ptr< rt_dobby_schema > &  containerConfig 
)

A logging sink that sends the contents of the container stdout/err to a given file. The file can have a size limit set.

Will create the requested file providing the directory exists. Creates a new file each time this class is instantiated

Member Function Documentation

◆ DumpLog()

void FileSink::DumpLog ( const int  bufferFd)
overridevirtual

Reads all the available data from the provided fd and writes it to the output file. Does not attempt to seek the file descriptor back to the start.

If file limit is hit, will send data to /dev/null

Parameters
[in]bufferFdThe fd to read from

Implements ILoggingSink.

◆ openFile()

int FileSink::openFile ( const std::string &  pathName)
private

Opens the log file at a given path. Will create a new file when called, and subsequent writes will append to the file.

Parameters
[in]pathNameWhere to create the file
Returns
Opened file descriptor

◆ process()

void FileSink::process ( const std::shared_ptr< AICommon::IPollLoop > &  pollLoop,
epoll_event  event 
)
overridevirtual

Called by the pollLoop when an event occurs on the container ptty.

Reads the contents of the ptty and logs to a file

Implements AICommon::IPollSource.


The documentation for this class was generated from the following files: