Public Member Functions | Private Member Functions | Private Attributes

AcsDaemonUtils Class Reference

#include <acsDaemonUtils.h>

Collaboration diagram for AcsDaemonUtils:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 AcsDaemonUtils ()
std::string getLogDirectory ()
std::string getLogDirectoryForContainer (std::string containerName)
std::string getTimestamp ()
std::string getSimpleContainerName (std::string containerName)
int checkWritePermission ()
int checkWritePermissionForContainer (std::string containerName)

Private Member Functions

int initLogDirectory ()
bool makeFolder (std::string path)
int checkWritePermission (std::string folder)

Private Attributes

std::string m_logDirectory

Constructor & Destructor Documentation

AcsDaemonUtils::AcsDaemonUtils (  ) 

Constructor


Member Function Documentation

int AcsDaemonUtils::checkWritePermission (  ) 

Check if the process has permission to write in the log folder where the log folder is returned by getLogDirectory()

Returns:
0 means that the folder is writable
int AcsDaemonUtils::checkWritePermission ( std::string  folder  )  [private]

Check if the process has permission to write in the passed log folder.

The test is done by creating a temporary file as this should be the most portable way.

int AcsDaemonUtils::checkWritePermissionForContainer ( std::string  containerName  ) 

Check if the process has permission to write in the log folder for the passed container name. The folder for the logs of container is built by AcsDaemonUtils::getLogDirectoryForContainer(...)

Returns:
0 means that the folder is writable
std::string AcsDaemonUtils::getLogDirectory (  )  [inline]

Get the directory to write the log files into.

Returns:
The returned path is usually $ACSDATA/logs/<HOST>/

References m_logDirectory.

std::string AcsDaemonUtils::getLogDirectoryForContainer ( std::string  containerName  ) 

The folder for the logs of a container is usually $ACSDATA/logs/<HOST>. If the container is hierarchical i.e it has a name like CONTROL/ACC/containerName then the logs go in $ACSDATA/logs/<HOST>/CONTROL/ACC/

If the folder does not exist, this method tries to build the folder setting the permissions too.

In case of error building the folder, it returns m_logDirectory.

Parameters:
containerName The name of the container
Returns:
The returned path is $ACSDATA/logs/<HOST>/containerName or $ACSDATA/logs/<HOST>/AAA/BBB/... if the container name is hierarchical
std::string AcsDaemonUtils::getSimpleContainerName ( std::string  containerName  ) 

Return the container name without the hierarchical part, that is:

  • the name if the container if it is not hierarchical
  • the last word after '\' if it is hierarchical
Returns:
the name of the container
std::string AcsDaemonUtils::getTimestamp (  ) 

Build a return a well formatted timestamp

int AcsDaemonUtils::initLogDirectory (  )  [private]

Init the log directory, m_logDirectory, from the ACSDATA environment variable, if defined.

If the folder does not exist, then initLogDirectory tries to create .
Note that this is the base folder for the logs i.e. ACSDATA/logs/host.

Returns:
0 if the folder exists and is writable 1 if ACSDATA does not exist or can't write in ACSDATA 2 error creating ACSDATA/logs 3 Can't write ACSDATA/logs 4 error getting the host name for HOST environment variable 5 Error creating ACSDATA/logs/<HOST> 6 Can't write ACSDATA/logs/<HOST>
bool AcsDaemonUtils::makeFolder ( std::string  path  )  [private]

Make the folder with the passed path.

Parameters:
path The path of the folder to create
Returns:
true If the folder has been successfully created false otherwise

Member Data Documentation

std::string AcsDaemonUtils::m_logDirectory [private]

The directory to write the logs.

Referenced by getLogDirectory().


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