00001 #ifndef logging_statistics_H 00002 #define logging_statistics_H 00003 /******************************************************************************* 00004 * ALMA - Atacama Large Millimiter Array 00005 * (c) Associated Universities Inc., 2005 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 * who when what 00022 * -------- -------- ---------------------------------------------- 00023 * mmanas 2014-11-11 created 00024 */ 00025 00030 #ifndef __cplusplus 00031 #error This is a C++ include file and cannot be used from plain C 00032 #endif 00033 00034 #include "acsutilTimeStamp.h" 00035 #include <list> 00036 #include <string> 00037 #include <stdint.h> 00038 00039 namespace Logging 00040 { 00041 // This class includes all cpp statistics aspects of the ACS logging system 00042 class loggingStatistics 00043 { 00044 private: 00045 // Boolean defining if the statistics module is active or inactive 00046 bool disableStatistics; 00047 // Identification string of the statistics. Composed by component name + logger name 00048 std::string statisticsIdentification; 00049 00050 // Number of valid messages logged during last period 00051 uint32_t accumulatedNumberOfMessages; 00052 // Number of logging errors generated during last period 00053 uint32_t accumulatedNumberOfLogErrors; 00054 // Last time instant of statistics calculation and repporting [timestamp] 00055 uint64_t lastStatisticsRepportTime; 00056 // Time between statistics calculation and repporting [in seconds] Default = 10 minutes 00057 uint32_t statisticsCalculationPeriod; 00058 // Granularity of the statistics [in seconds]. Default = 1 second 00059 uint32_t statisticsGranularity; 00060 // Last period backup of accumulatedNumberOfMessages 00061 uint32_t lastPeriodNumberOfMessages; 00062 // Last period backup of accumaltedNumberOfLogErrors 00063 uint32_t lastPeriodNumberOfLogErrors; 00064 00065 // Statistics calculation 00066 float messageStatistics; // Calculated message statistics 00067 float errorStatistics; // Calculated error statistics 00068 float messageIncrement; // Calculated increment of messages 00069 float errorIncrement; // Calculated increment of logging errors 00070 float actualStatisticsPeriod; // Actual statistics calculation period 00071 00072 public: 00073 // Getter for disableStatistics 00074 bool getDisableStatistics(); 00075 00076 // Getter for statisticsIdentification 00077 std::string getStatisticsIdentification(); 00078 00079 // Getter for accumulatedNumberOfMessages 00080 uint32_t getAccumulatedNumberOfMessages(); 00081 00082 // Getter for accumaltedNumberOfLogErrors 00083 uint32_t getAccumulatedNumberOfLogErrors(); 00084 00085 // Getter for statisticsGranularity 00086 uint32_t getStatisticsGranularity(); 00087 00088 // Getter for lastPeriodNumberOfMessages 00089 uint32_t getLastPeriodNumberOfMessages(); 00090 00091 // Getter for lastPeriodNumberOfLogErrors 00092 uint32_t getLastPeriodNumberOfLogErrors(); 00093 00094 // Getter for lastStatisticsRepportTime 00095 uint64_t getLastStatisticsRepportTime(); 00096 00097 // Getter for statisticsCalculationPeriod 00098 uint32_t getStatisticsCalculationPeriod(); 00099 00100 // Setter for accumulatedNumberOfMessages 00101 void setAccumulatedNumberOfMessages(uint32_t value); 00102 00103 // Setter for accumulatedNumberOfLogErrors 00104 void setAccumulatedNumberOfLogErrors(uint32_t value); 00105 00106 // Setter for lastStatisticsRepportTime 00107 void setLastStatisticsRepportTime(uint64_t value); 00108 00109 // Setter for statisticsCalculationPeriod 00110 void setStatisticsCalculationPeriod(uint32_t value); 00111 00112 // Setter for statisticsGranularity 00113 void setStatisticsGranularity(uint32_t value); 00114 00115 // Setter for lastPeriodNumberOfMessages 00116 void setLastPeriodNumberOfMessages(uint32_t value); 00117 00118 // Setter for lastPeriodNumberOfMessages 00119 void setLastPeriodNumberOfLogErrors(uint32_t value); 00120 00121 // Default constructor 00122 loggingStatistics(); 00123 00124 // Default destructor 00125 virtual ~loggingStatistics(){} 00126 00131 virtual void 00132 calculateLoggingStatistics(); 00133 00140 virtual void 00141 retrieveStatisticsLogs(std::list<std::string> &statisticsLogList, 00142 const std::string loggerId); 00143 00148 virtual void incrementNumberOfMessages(); 00149 00154 virtual void incrementNumberOfLogErrors(); 00155 00160 virtual void resetStatistics(); 00161 00171 virtual void configureStatistics(const std::string elementName, 00172 const bool state, 00173 const uint32_t period, 00174 const uint32_t granularity); 00175 00179 static const uint32_t INITIAL_NUMBER_MESSAGES; 00180 static const uint32_t INITIAL_NUMBER_ERRORS; 00181 static const uint32_t DEFAULT_STATISTICS_PERIOD; 00182 static const uint32_t DEFAULT_STATISTICS_GRANULARITY; 00183 static const bool DEFAULT_STATISTICS_STATE; 00184 00185 }; 00186 00187 }; 00188 00189 #endif /*logging_statistics_H*/