00001 #ifndef ACSDAEMONS_UTILS_H 00002 #define ACSDAEMONS_UTILS_H 00003 /******************************************************************************* 00004 * ALMA - Atacama Large Millimiter Array 00005 * Copyright (c) European Southern Observatory, 2013 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 * 00022 * who when what 00023 * -------- -------- ---------------------------------------------- 00024 * acaproni 2013-05-22 created 00025 */ 00026 00027 /************************************************************************ 00028 * A utility class for logging from the daemons. 00029 * 00030 * The log directory defaults to "~/.acs/commandcenter/" but it is redefined 00031 * if ACSDATA env. variable is defined. In that case the folder name 00032 * is $ACSDATA/logs/host/. 00033 * 00034 *---------------------------------------------------------------------- 00035 */ 00036 00037 #ifndef __cplusplus 00038 #error This is a C++ include file and cannot be used from plain C 00039 #endif 00040 00041 #include <string> 00042 00043 class AcsDaemonUtils { 00044 private: 00048 std::string m_logDirectory; 00049 00050 public: 00051 00055 AcsDaemonUtils(); 00056 00062 std::string getLogDirectory() { return m_logDirectory; } 00063 00078 std::string getLogDirectoryForContainer(std::string containerName); 00079 00083 std::string getTimestamp(); 00084 00092 std::string getSimpleContainerName(std::string containerName); 00093 00100 int checkWritePermission(); 00101 00110 int checkWritePermissionForContainer(std::string containerName); 00111 00112 private: 00113 00128 int initLogDirectory(); 00129 00137 bool makeFolder(std::string path); 00138 00146 int checkWritePermission(std::string folder); 00147 00148 }; 00149 00150 #endif