Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

loggingLoggingProxy.h

Go to the documentation of this file.
00001 #ifndef logging_logging_proxy_H 00002 #define logging_logging_proxy_H 00003 00004 /******************************************************************************* 00005 * ALMA - Atacama Large Millimiter Array 00006 * (c) European Southern Observatory, 2002 00007 * Copyright by ESO (in the framework of the ALMA collaboration) 00008 * and Cosylab 2002, All rights reserved 00009 * 00010 * This library is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU Lesser General Public 00012 * License as published by the Free Software Foundation; either 00013 * version 2.1 of the License, or (at your option) any later version. 00014 * 00015 * This library is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public 00021 * License along with this library; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 * 00024 * "@(#) $Id: loggingLoggingProxy.h,v 1.35 2008/08/05 15:46:07 bjeram Exp $" 00025 * 00026 * who when what 00027 * -------- ---------- ---------------------------------------------- 00028 * bjeram 2003-03-06 added #include <ace/Log_Record.h> (needed by ACE/TAO x.3) 00029 * bjeram 2002-04-10 added setStdio 00030 * msekoran 2001-12-17 added CL failure detection, logging to syslog, file, ... 00031 * bjeram 2001-09-13 added logXML(...) method 00032 * bjeram 2001-08 added ACS_LOG_TIME macro 00033 * msekoran 2001-07-12 renamed m_data and m_flags variables in LoggingTSSStorage class 00034 * msekoran 2001-06-08 Implementation according new specifications 00035 * almamgr 2000-12-03 Removed static and changed to char* from filename and oldfilename 00036 * almamgr 2000-12-03 created 00037 */ 00038 00039 #ifndef __cplusplus 00040 #error This is a C++ include file and cannot be used from plain C 00041 #endif 00042 00043 #include <ace/Log_Msg_Callback.h> 00044 00045 #include <deque> 00046 00047 #include <orbsvcs/orbsvcs/DsLogAdminC.h> 00048 #include <orbsvcs/CosNamingC.h> 00049 00050 #include <ace/Synch.h> 00051 #include "logging_idlC.h" 00052 00053 #include "loggingExport.h" 00054 #include "loggingLoggingTSSStorage.h" 00055 00056 #define DYNAMIC_LOG_LEVEL 1 00057 #define CDB_REFRESH_LOG_LEVEL 2 00058 #define ENV_LOG_LEVEL 3 00059 #define CDB_LOG_LEVEL 4 00060 #define DEFAULT_LOG_LEVEL 5 00061 #define NOT_DEFINED_LOG_LEVEL 6 00062 00064 #define ADD_DATA_VALUE_MAX 256 00065 00068 #define LM_RUNTIME_CONTEXT 0x00000200 00069 00072 #define LM_SOURCE_INFO 0x00000100 00073 00075 #define LM_FULL_INFO (LM_RUNTIME_CONTEXT | LM_SOURCE_INFO) 00076 00118 class logging_EXPORT LoggingProxy : public ACE_Log_Msg_Callback 00119 { 00120 00121 public: 00124 void log(ACE_Log_Record &log_record); 00125 00130 static void LogEntryType(const ACE_TCHAR *szType); 00131 00135 static void Routine(const ACE_TCHAR *szRoutine); 00136 00140 static void File(const ACE_TCHAR *fileName); 00141 00145 static void Line(long lineNumber); 00146 00151 static void Flags(unsigned int uiFlags); 00152 00155 static void ThreadName(const ACE_TCHAR *szName); 00156 00158 static const ACE_TCHAR *ThreadName(); 00159 00162 static void ProcessName(const ACE_TCHAR *szName); 00163 00165 static const ACE_TCHAR *ProcessName(); 00166 00169 static void ResetAttributes(); 00170 00172 static void AddAttribute(const ACE_TCHAR *szName, const ACE_TCHAR *szValue); 00173 00176 static void LogId(const ACE_TCHAR *szName); 00177 00180 static void URI(const ACE_TCHAR *szName); 00181 00185 static void StackId(const ACE_TCHAR *szId); 00186 00189 static const ACE_TCHAR *StackId(); 00190 00192 static void PrivateFlags(int privateFlags); 00193 00195 static const int PrivateFlags(); 00196 00197 static void LogLevelLocalType(int logLevelLocalType); 00198 00199 static const int LogLevelLocalType(); 00200 00201 static void LogLevelRemoteType(int logLevelRemoteType); 00202 00203 static const int LogLevelRemoteType(); 00204 00207 static void StackLevel(int nLevel); 00208 00210 static int StackLevel(); 00211 00214 static void Context(const ACE_TCHAR *szName); 00215 00217 static const ACE_TCHAR *Context(); 00218 00222 static void SourceObject(const ACE_TCHAR *soName); 00223 00226 static const ACE_TCHAR * SourceObject(); 00227 00229 static void audience(const ACE_TCHAR *aud); 00230 00233 static const ACE_TCHAR * audience(); 00234 00236 static void array(const ACE_TCHAR *aud); 00237 00240 static const ACE_TCHAR * array(); 00241 00243 static void antenna(const ACE_TCHAR *aud); 00244 00247 static const ACE_TCHAR * antenna(); 00248 00250 static void host(const ACE_TCHAR *aud); 00251 00254 static const ACE_TCHAR * host(); 00255 00258 static void AddData(const ACE_TCHAR *szName, const ACE_TCHAR *szFormat, ...); 00259 00260 public: 00261 00264 LoggingProxy(const unsigned long cacheSize, 00265 const unsigned long minCachePriority, 00266 const unsigned long maxCachePriority, 00267 DsLogAdmin::Log_ptr centralizedLogger = DsLogAdmin::Log::_nil(), 00268 CosNaming::NamingContext_ptr namingContext = CosNaming::NamingContext::_nil(), 00269 const unsigned int autoFlushTimeoutSec = 5); 00270 00272 ~LoggingProxy(); 00273 00275 void setCentralizedLogger(DsLogAdmin::Log_ptr centralizedLogger); 00276 00278 void setNamingContext(CosNaming::NamingContext_ptr namingContext) 00279 { 00280 m_namingContext = CosNaming::NamingContext::_duplicate(namingContext); 00281 } 00282 00284 void flush(); 00285 00287 void setStdio(int stdio){ m_envStdioPriority = stdio; } 00288 00290 //static ACE_TCHAR* m_LogEntryTypeName[]; 00291 //static ACSLoggingLog::LogType m_LogBinEntryTypeName[]; 00292 00294 static void init(LoggingProxy *loggingProxy); 00295 00297 static void done(); 00298 static std::string BinToXml(ACSLoggingLog::LogBinaryRecord* record); 00299 00303 static unsigned long getPriority(ACE_Log_Record &log_record); 00304 00306 void logXML(const ACE_TCHAR *xml, bool cache=true); 00307 00309 static bool isInit() 00310 { 00311 return initialized; 00312 } 00313 00315 static bool isInitThread(); 00316 00318 int getCacheLogCount() const { if(!m_logBin) return m_cache.size(); else return m_bin_cache.size();} 00319 00320 private: 00321 00323 static void formatISO8601inUTC(const ACE_Time_Value &timestamp, ACE_TCHAR str[]); 00324 00326 void failedToSend(); 00327 00329 void successfullySent(); 00330 00332 bool reconnectToLogger(); 00333 00335 void sendCache(); 00336 00338 void sendCacheInternal(); 00339 00342 bool sendRecord(CORBA::Any &record); 00343 00344 void sendXmlLogs(ACE_Log_Record &log_record, const ACE_TCHAR * timestamp, const ACE_TCHAR * entryType); 00345 void sendBinLogs(ACE_Log_Record &log_record, const ACE_TCHAR * timestamp, const ACE_TCHAR * entryType); 00346 00353 unsigned long m_cacheSize; 00354 00361 unsigned long m_minCachePriority; 00362 00368 unsigned long m_maxCachePriority; 00369 00373 unsigned int m_autoFlushTimeoutSec; 00374 00379 DsLogAdmin::Log_var m_logger; 00380 bool m_noLogger; 00381 00386 CosNaming::NamingContext_var m_namingContext; 00387 00390 int m_failureCount; 00391 00393 static int m_failureLimit; 00394 00397 ACE_Time_Value m_disconnectionTime; 00398 00400 static int m_minReconnectionTime; 00401 00405 typedef std::deque<ACE_CString> LogDeque; 00406 LogDeque m_cache; 00407 00408 00409 typedef std::deque<ACSLoggingLog::LogBinaryRecord *> LogBinDeque; 00410 //typedef std::deque<ACSLoggingLog::LogBinaryRecord > LogBinDeque; 00411 LogBinDeque m_bin_cache; 00412 00413 // ACSLoggingLog::LogBinaryRecord * m_binaryRecord; 00414 00416 bool m_cacheDisabled; 00417 00421 static char /*ACE_CString*/ m_process[256]; 00422 00426 ACE_Recursive_Thread_Mutex m_mutex; 00427 00428 bool m_logBin; 00429 00433 static ACE_TSS<LoggingTSSStorage> * tss; 00434 static int instances; 00435 00437 ACE_CString m_filename; 00438 00440 bool m_alreadyInformed; 00441 00445 int m_envStdioPriority; 00446 int m_envCentralizePriority; 00447 00452 ACE_CString m_syslog; 00453 00455 static bool initialized; 00456 00457 static ACE_CString sourceObject_m; 00458 00461 static unsigned int setClrCount_m; 00462 00464 ACE_SYNCH_MUTEX m_doWorkMutex; 00465 00467 ACE_SYNCH_CONDITION m_doWorkCond; 00468 00470 volatile bool m_sendingPending; 00471 00473 virtual int svc(); 00474 00476 static void* worker(void*); 00477 00479 volatile bool m_threadCreated; 00481 //ACE_Barrier m_threadStart; 00483 ACE_Barrier m_threadShutdown; 00484 volatile bool m_shutdown; 00485 }; 00486 00487 #endif

Generated on Thu Apr 30 02:30:51 2009 for ACS C++ API by doxygen 1.3.8