Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
LoggingPlugin Class Reference

Dobby Logging plugin. More...

#include <LoggingPlugin.h>

Inheritance diagram for LoggingPlugin:
Inheritance graph
[legend]
Collaboration diagram for LoggingPlugin:
Collaboration graph
[legend]

Public Member Functions

 LoggingPlugin (std::shared_ptr< rt_dobby_schema > &containerConfig, const std::shared_ptr< DobbyRdkPluginUtils > &utils, const std::string &rootfsPath)
 Constructor - called when plugin is loaded by PluginLauncher. More...
 
std::string name () const override
 Should return the name of the plugin. More...
 
unsigned hookHints () const override
 Set the bit flags for which hooks we're going to use. More...
 
bool postInstallation () override
 Set the correct options in the config file.
 
std::vector< std::string > getDependencies () const override
 Should return the names of the plugins this plugin depends on. More...
 
void RegisterPollSources (int fd, std::shared_ptr< AICommon::IPollLoop > pollLoop) override
 Adds the necessary poll source(s) to the provided pollLoop instance based on the logging sink specified in the container config. More...
 
void DumpToLog (const int bufferFd) override
 Dump the contents of a file descriptor to the log sink. More...
 
- Public Member Functions inherited from DobbyLoggerBase
virtual bool preCreation ()
 
virtual bool createRuntime ()
 
virtual bool createContainer ()
 
virtual bool postStart ()
 
virtual bool postHalt ()
 
virtual bool postStop ()
 

Private Types

enum class  LoggingSink { DevNull , File , Journald }
 

Private Member Functions

std::shared_ptr< ILoggingSinkCreateSink (LoggingSink sinkType)
 Constructs an instance of the requested sink. More...
 
LoggingSink GetContainerSink ()
 Converts the "sink: xxx" in the config to a valid log sink. Case insensitive.
 

Private Attributes

const std::string mName
 
std::shared_ptr< rt_dobby_schema > mContainerConfig
 
const std::shared_ptr< DobbyRdkPluginUtilsmUtils
 
std::shared_ptr< ILoggingSinkmSink
 
std::shared_ptr< AICommon::IPollLoopmPollLoop
 

Additional Inherited Members

- Public Types inherited from IDobbyRdkPlugin
enum  HintFlags : unsigned {
  PostInstallationFlag = (1 << 0) , PreCreationFlag = (1 << 1) , CreateRuntimeFlag = (1 << 2) , CreateContainerFlag = (1 << 3) ,
  PostStartFlag = (1 << 5) , PostHaltFlag = (1 << 6) , PostStopFlag = (1 << 7) , Unknown = 0
}
 Bit flags that should be returned by hookHints. More...
 

Detailed Description

Dobby Logging plugin.

Constructor & Destructor Documentation

◆ LoggingPlugin()

LoggingPlugin::LoggingPlugin ( std::shared_ptr< rt_dobby_schema > &  containerConfig,
const std::shared_ptr< DobbyRdkPluginUtils > &  utils,
const std::string &  rootfsPath 
)

Constructor - called when plugin is loaded by PluginLauncher.

Do not change the parameters for this constructor - must match C methods created by REGISTER_RDK_PLUGIN macro

Note plugin name is not case sensitive

Member Function Documentation

◆ CreateSink()

std::shared_ptr< ILoggingSink > LoggingPlugin::CreateSink ( LoggingPlugin::LoggingSink  sinkType)
private

Constructs an instance of the requested sink.

Parameters
[in]sinkTypeThe type of sink to be constructed
Returns
shared_ptr pointing to the instance of the logging sink. Nullptr if no sink of the requested type is available

◆ DumpToLog()

void LoggingPlugin::DumpToLog ( const int  bufferFd)
overridevirtual

Dump the contents of a file descriptor to the log sink.

Will block until the contents of the fd has been written to the log

Parameters
[in]bufferFdThe file descriptor to read from

Implements IDobbyRdkLoggingPlugin.

◆ getDependencies()

std::vector< std::string > LoggingPlugin::getDependencies ( ) const
overridevirtual

Should return the names of the plugins this plugin depends on.

This can be used to determine the order in which the plugins should be processed when running hooks.

Returns
Names of the plugins this plugin depends on.

Reimplemented from DobbyLoggerBase.

◆ hookHints()

unsigned LoggingPlugin::hookHints ( ) const
overridevirtual

Set the bit flags for which hooks we're going to use.

This plugin uses all the hooks so set all the flags

Implements IDobbyRdkPlugin.

◆ name()

std::string LoggingPlugin::name ( ) const
inlineoverridevirtual

Should return the name of the plugin.

Returns
string with the name of the hook.

Implements IDobbyRdkPlugin.

◆ RegisterPollSources()

void LoggingPlugin::RegisterPollSources ( int  fd,
std::shared_ptr< AICommon::IPollLoop pollLoop 
)
overridevirtual

Adds the necessary poll source(s) to the provided pollLoop instance based on the logging sink specified in the container config.

Parameters
[in]fdThe file descriptor we need to read from (i.e. the container tty)
[in]pollLoopThe poll loop the sources should be added to

Implements IDobbyRdkLoggingPlugin.


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