130 likes | 249 Views
ACS Logging System APIs: C++. Bogdan Jeram (bjeram@eso.org) European Southern Observatory. July 2004. NRAO. Architecture. Application (non C++ & Java). ACS log SVC. Application (C++). Client jlog. Notification channel. Centralized logger (Telecom Log COS). L A o g
E N D
ACSLogging System APIs: C++ Bogdan Jeram (bjeram@eso.org) European Southern Observatory July 2004 NRAO
Architecture Application(non C++ & Java) ACS log SVC Application (C++) Clientjlog Notificationchannel Centralizedlogger(Telecom Log COS) LA o g C g IE n g L o pg rg oI xn yg macro client macro client macro local cache - file macro stdout - screen ACS Logging System APIs: C++
Logging System in C++ • based on ACE logging • defined callback (LoggingProxy) • defined macros • implementation of Centralized Log e.g. Telecom Log CORBA service • ACS Log SVCS ACS Logging System APIs: C++
Initialisation • should be done in every thread ! • already done by the Container and the Simple client • LoggingProxy m_logger (cacheSize, minCachePrio, maxCachePrio);LoggingProxy::init (&m_logger); • additional configuration: host name, centralized logger, … • LoggingProxy::done(); ACS Logging System APIs: C++
C++ log macros Generic: ACS_LOG (flag, routine, log) log:ACE log message: (log type, msg) ACS Logging System APIs: C++
ACE log messages • Flags: • LM_RUNTIME_CONTEXT • LM_SOURCE_INFO • Log types and default priorities: • LM_TRACE (2) • LM_DEBUG (3) • LM_INFO (4) • LM_NOTICE (5) • LM_WARNING (6) • LM_ERROR (8) • LM_CRITICAL (9) • LM_ALERT (10) • LM_EMERGENCY (11) ACS Logging System APIs: C++
C++ log macros Specialized: • ACS_DEBUG( routine, msg) • ACS_DEBUG_PARAM (routine, msg, param) • ACS_TRACE (routine) • ACS_SHORT_LOG (log) ACS Logging System APIs: C++
Examples of creating a message • ACS_DEBUG("BaciTestClass::~BaciTestClass“, "COB destroyed“); • ACS_LOG(LM_RUNTIME_CONTEXT, "maci::ActivatorImpl::init", (LM_INFO, "Activator '%s' initialized successfuly", m_activator_name)); ACS Logging System APIs: C++
Configuring • at construction time: LoggingProxy • via the Configuration Database:<Activator CacheSize="10“ MinCachePriority="0“ MaxCachePriority="31“ CentralizedLogger="Log"></Activator> • environment variables: • set the priority for sending logs to stdout: ACS_LOG_STDOUT • set the file for the local cache: ACS_LOG_FILE ACS Logging System APIs: C++
ACS log service • ACS service • started with: acsStartORBSVC • access to the ACS logging system if native support for logging is not available • reference can be obtained via the Manager (ACSLogSvc) ACS Logging System APIs: C++
IDL interface LogSvc void logTrace(in TimeStamp time, in string msg, in RTContext rtCont, in SourceInfo srcInfo, in NVPairSeq data) raises (ACSErr::ACSException); void logDebug(in TimeStamp time, in string msg, in RTContext rtCont, in SourceInfo srcInfo, in NVPairSeq data) raises (ACSErr::ACSException);void logInfo(in TimeStamp time, in string msg, in RTContext rtCont, in SourceInfo srcInfo, in NVPairSeq data) raises (ACSErr::ACSException);void logNotice(in TimeStamp time, in string msg, in RTContext rtCont, in SourceInfo srcInfo, in NVPairSeq data) raises (ACSErr::ACSException);void logWarning(in TimeStamp time, in string msg, in RTContext rtCont, in SourceInfo srcInfo, in NVPairSeq data) raises (ACSErr::ACSException);void logError(in ACSErr::ErrorTrace c) raises (ACSErr::ACSException);void logCritical(in TimeStamp time, in string msg, in RTContext rtCont, in SourceInfo srcInfo, in NVPairSeq data) raises (ACSErr::ACSException);void logAlert(in TimeStamp time, in string msg, in RTContext rtCont, in SourceInfo srcInfo, in NVPairSeq data) raises (ACSErr::ACSException);void logEmergency(in TimeStamp time, in string msg, in RTContext rtCont, in SourceInfo srcInfo, in NVPairSeq data) raises (ACSErr::ACSException);void logXML(in XMLstring xml) raises (ACSErr::ACSException); }; ACS Logging System APIs: C++
References • Logging and Archiving:http://www.eso.org/~gchiozzi/AlmaAcs/OnlineDocs/Logging_and_Archiving.pdf • logging doxygen documentation:$ACSROOT/man/cpp/logging_8h.html • ACS Log SVCS doxygen documentation: $ACSROOT/man/idl/acslog_8idl.html ACS Logging System APIs: C++
Exercises • Put into your example some log message: • trace messages: ACS_TRACE • debug message: ACS_DEBUG • try to replace ACS__TRACE/ACS_DEBUG with ACS_LOG (try different combination of flags) • play with environment variables: • ACS_LOG_STDOUT • ACS_LOG_FILE • try jlog log client ACS Logging System APIs: C++