#include <loggingLoggingProxy.h>
Public Member Functions | |
void | log (ACE_Log_Record &log_record) |
LoggingProxy (const unsigned long cacheSize, const unsigned long minCachePriority, const unsigned long maxCachePriority, DsLogAdmin::Log_ptr centralizedLogger=DsLogAdmin::Log::_nil(), CosNaming::NamingContext_ptr namingContext=CosNaming::NamingContext::_nil(), const unsigned int autoFlushTimeoutSec=5) | |
~LoggingProxy () | |
Destructor. | |
void | setCentralizedLogger (DsLogAdmin::Log_ptr centralizedLogger) |
Set Centralized Logger. | |
void | setNamingContext (CosNaming::NamingContext_ptr namingContext) |
Set Naming Context. | |
void | flush () |
Forces logger to flush cache. Thread safe! | |
void | setStdio (int stdio) |
Sets ACS_LOG_STDOUT runtime. | |
void | logXML (const ACE_TCHAR *xml, bool cache=true) |
Checks xml if it is XML and "DTD" string and send it to centralized logger. Thread safe! | |
int | getCacheLogCount () const |
For testing only (not tread-safe). | |
Static Public Member Functions | |
void | LogEntryType (const ACE_TCHAR *szType) |
void | Routine (const ACE_TCHAR *szRoutine) |
void | File (const ACE_TCHAR *fileName) |
void | Line (long lineNumber) |
void | Flags (unsigned int uiFlags) |
void | ThreadName (const ACE_TCHAR *szName) |
const ACE_TCHAR * | ThreadName () |
Returns the name of the thread. | |
void | ProcessName (const ACE_TCHAR *szName) |
const ACE_TCHAR * | ProcessName () |
Returns the name of the process. | |
void | ResetAttributes () |
void | AddAttribute (const ACE_TCHAR *szName, const ACE_TCHAR *szValue) |
Add an attribute to the list of next log entries� attributes. | |
void | LogId (const ACE_TCHAR *szName) |
void | URI (const ACE_TCHAR *szName) |
void | StackId (const ACE_TCHAR *szId) |
const ACE_TCHAR * | StackId () |
void | PrivateFlags (int privateFlags) |
Private flags (to be used only internally). | |
const int | PrivateFlags () |
Private flags (to be used only internally). | |
void | LogLevelLocalType (int logLevelLocalType) |
const int | LogLevelLocalType () |
void | LogLevelRemoteType (int logLevelRemoteType) |
const int | LogLevelRemoteType () |
void | StackLevel (int nLevel) |
int | StackLevel () |
Retrieve the stack level in the current logical thread. | |
void | Context (const ACE_TCHAR *szName) |
const ACE_TCHAR * | Context () |
Retrieve the context in which the code is operating. | |
void | SourceObject (const ACE_TCHAR *soName) |
const ACE_TCHAR * | SourceObject () |
void | audience (const ACE_TCHAR *aud) |
Set the audience intended for the log message. | |
const ACE_TCHAR * | audience () |
void | array (const ACE_TCHAR *aud) |
Set the array where the log message was generated. | |
const ACE_TCHAR * | array () |
void | antenna (const ACE_TCHAR *aud) |
Set the antenna where the log message was generated. | |
const ACE_TCHAR * | antenna () |
void | host (const ACE_TCHAR *aud) |
Set the host where the log message was generated. | |
const ACE_TCHAR * | host () |
void | AddData (const ACE_TCHAR *szName, const ACE_TCHAR *szFormat,...) |
void | init (LoggingProxy *loggingProxy) |
initializes ACE_LOG_MSG (must be done per each thread) | |
void | done () |
returns ACE_LOG_MSG to default state | |
std::string | BinToXml (ACSLoggingLog::LogBinaryRecord *record) |
unsigned long | getPriority (ACE_Log_Record &log_record) |
bool | isInit () |
Returns true if loggin is initialized otherwise false. | |
bool | isInitThread () |
Returns true if logging is initialized in this thread. | |
Private Types | |
typedef std::deque< ACE_CString > | LogDeque |
typedef std::deque< ACSLoggingLog::LogBinaryRecord * > | LogBinDeque |
Private Member Functions | |
void | failedToSend () |
Method to be called when CORBA invocation to the centralized logger failed. | |
void | successfullySent () |
Method to be called when CORBA invocation to the centralized logger was successful. | |
bool | reconnectToLogger () |
Tries to reconnect to the centralized logger (after some amount of time) and return <true> if successful. | |
void | sendCache () |
Send local cache file to the centralized logger (Telecom log service). | |
void | sendCacheInternal () |
Send local cache file to the centralized logger (Telecom log service). | |
bool | sendRecord (CORBA::Any &record) |
void | sendXmlLogs (ACE_Log_Record &log_record, const ACE_TCHAR *timestamp, const ACE_TCHAR *entryType) |
void | sendBinLogs (ACE_Log_Record &log_record, const ACE_TCHAR *timestamp, const ACE_TCHAR *entryType) |
virtual int | svc () |
Thread entry point (thread worker). | |
Static Private Member Functions | |
void | formatISO8601inUTC (const ACE_Time_Value ×tamp, ACE_TCHAR str[]) |
Get time in ISO8601 format in UTC (eg. 2000-12-31T08:12:21.322) - 24 chars (incl. ). | |
void * | worker (void *) |
Static thread worker (calls svc). | |
Private Attributes | |
unsigned long | m_cacheSize |
unsigned long | m_minCachePriority |
unsigned long | m_maxCachePriority |
unsigned int | m_autoFlushTimeoutSec |
DsLogAdmin::Log_var | m_logger |
bool | m_noLogger |
CosNaming::NamingContext_var | m_namingContext |
int | m_failureCount |
ACE_Time_Value | m_disconnectionTime |
LogDeque | m_cache |
LogBinDeque | m_bin_cache |
bool | m_cacheDisabled |
Cache state. | |
ACE_Recursive_Thread_Mutex | m_mutex |
bool | m_logBin |
ACE_CString | m_filename |
Local output file, if Centralized Logger is unavailable (set by ACE_LOG_FILE env. var). | |
bool | m_alreadyInformed |
Switch to inform client only once about logging to the file. | |
int | m_envStdioPriority |
int | m_envCentralizePriority |
ACE_CString | m_syslog |
ACE_SYNCH_MUTEX | m_doWorkMutex |
The mutual exclusion mechanism which is required to use the <m_workworkcond>. | |
ACE_SYNCH_CONDITION | m_doWorkCond |
Work condition. | |
volatile bool | m_sendingPending |
Sending pending... | |
volatile bool | m_threadCreated |
Thread creation flag. | |
ACE_Barrier | m_threadShutdown |
Thread shutdown barrier. | |
volatile bool | m_shutdown |
Static Private Attributes | |
int | m_failureLimit |
Failure count limit. | |
int | m_minReconnectionTime |
Reconnection retry (minimum time in sec). | |
char | m_process [256] |
ACE_TSS< LoggingTSSStorage > * | tss |
int | instances |
bool | initialized |
Initialization flag. | |
ACE_CString | sourceObject_m |
unsigned int | setClrCount_m |
// initialize ACE logger instance ACE_TCHAR hostname[33]; ACE_OS::hostname (hostname, sizeof(hostname)); ACE_Log_Msg::instance()->local_host(hostname);
LoggingProxy * logger = new LoggingProxy(cacheSize, minCachePriority, maxCachePriority, telecomLogger.in(), namingContext.in()); if (logger) { LoggingProxy::init(logger); LoggingProxy::ProcessName(argv[0]); LoggingProxy::ThreadName("main"); }
WARNING: When LoggingProxy is configured to log to the centralized logger, this means remote logging using CORBA, user of the LoggingProxy is obligated to disable remote logging before shutting down CORBA, i.e. calling CORBA::ORB::shutdown() or CORBA::ORB::destroy() metods. This is simply done by setting centralized logger refernce to nil. An example: if (logger) { logger->flush(); logger->setCentralizedLogger(DsLogAdmin::Log::_nil()); }
LoggingProxy is also configurable via next enivronment variables:
|
|
|
Local cache |
|
Constructor WARNING: LoggingProxy MUST be created before calling any of its static methods! |
|
Destructor.
|
|
Add an attribute to the list of next log entries� attributes.
|
|
Supply data with the log entry that follows. The maximum lenghth for AddData value is ADD_DATA_VALUE_MAX (255+). If it is too long it will be truncated. |
|
Return the antenna. The name is global per thread (stored in thread-specific storage TSS) |
|
Set the antenna where the log message was generated.
|
|
Return the array. The name is global per thread (stored in thread-specific storage TSS) |
|
Set the array where the log message was generated.
|
|
Return the audience. The name is global per thread (stored in thread-specific storage TSS) |
|
Set the audience intended for the log message.
|
|
|
|
Retrieve the context in which the code is operating.
|
|
Set the context in which the code is operating. Pointer to the name must be stored in the thread-specific storage! |
|
returns ACE_LOG_MSG to default state
|
|
Method to be called when CORBA invocation to the centralized logger failed.
|
|
Specifies the name of the file where the following log entry will be generated. Pointer to the string must be stored in the thread-specific storage! |
|
Set the flags that will apply to the log entry that will be submitted next. Flags must be stored in thread-specific storage! Flags are obtained by OR-ing appropriate LM_* values above. If priority is 0, the default priority associated with ACE's log entry type (LM_INFO, LM_ERROR, ...) is implied. |
|
Forces logger to flush cache. Thread safe!
|
|
Get time in ISO8601 format in UTC (eg. 2000-12-31T08:12:21.322) - 24 chars (incl. ).
|
|
For testing only (not tread-safe).
|
|
Returns priority of the record (default or overriden). It returns ACS priority which is ACE priority increased by 1. in the past ACE and ACS priorities were aligned, due a bug in ACS's log2! |
|
Return the host The name is global per thread (stored in thread-specific storage TSS) |
|
Set the host where the log message was generated.
|
|
initializes ACE_LOG_MSG (must be done per each thread)
|
|
Returns true if loggin is initialized otherwise false.
|
|
Returns true if logging is initialized in this thread.
|
|
Specifies the name of the file where the following log entry will be generated. Pointer to the string must be stored in the thread-specific storage! |
|
Receives all log entries submited within the process. Thread safe! |
|
Specifies the log entry type, if the output representation is different than the one implied with ACE�s log entry type. Applies for the next log entry only. Pointer to the string must be stored in the thread-specific storage! |
|
Specify the LogId attribute of the log entry that follows. Can be 0 (default) in which case no LogId attribute is output. |
|
|
|
|
|
|
|
|
|
Checks xml if it is XML and "DTD" string and send it to centralized logger. Thread safe!
|
|
Private flags (to be used only internally).
|
|
Private flags (to be used only internally).
|
|
Returns the name of the process.
|
|
Specifies the name of the process. Must be stored in a process-wide global variable! |
|
Tries to reconnect to the centralized logger (after some amount of time) and return <true> if successful.
|
|
Reset the list of custom attributes. The attributes are applicable to the next log entry only. |
|
Specifies the name of the routine (function) where the following log entry will be generated. Pointer to the string must be stored in the thread-specific storage! |
|
|
|
Send local cache file to the centralized logger (Telecom log service).
|
|
Send local cache file to the centralized logger (Telecom log service).
|
|
Send given record to the centralized logger (Telecom log service) Return: true if successful, false on failure |
|
|
|
Set Centralized Logger.
|
|
Set Naming Context.
|
|
Sets ACS_LOG_STDOUT runtime.
|
|
Return the name of the source object set by SourceObject The name is global per thread (stored in thread-specific storage TSS) |
|
Set the name of the object which is publishing the log. Pointer to the name must be stored in the thread-specific storage! |
|
Returns the the logical thread ID. Must have been set previously using StackId. |
|
Specifies the stack ID of the current logical thread. Pointer to the name must be stored in the thread-specific storage! Can be set to NULL if the logical thread ID is unknown. |
|
Retrieve the stack level in the current logical thread.
|
|
Set the stack level in the current logical thread. The value must be stored in the thread-specific storage! |
|
Method to be called when CORBA invocation to the centralized logger was successful.
|
|
Thread entry point (thread worker).
|
|
Returns the name of the thread.
|
|
Specifies the name of the thread. Pointer to the name must be stored in the thread-specific storage! |
|
Specify the URI attribute of the log entry that follows. Can be 0 (default) in which case no URI attribute is output. |
|
Static thread worker (calls svc).
|
|
Initialization flag.
|
|
|
|
Switch to inform client only once about logging to the file.
|
|
Timeout in seconds to auto-flush (send cache). |
|
|
|
|
|
Cache state.
|
|
The number of log entries that can be kept in the local cache. When this number is reached, all log entries are transferred to the centralized logging. If network connection is not available, the local cache continues to grow, and every submitting of a log entry will attempt to flush the cache to the centralized logging. |
|
The time CL was disabled. LoggingProxy will try to reconnect after some (defined) time. |
|
Work condition.
|
|
The mutual exclusion mechanism which is required to use the <m_workworkcond>.
|
|
|
|
Priority of logs to be sent to STDIO (set by ACE_LOG_STDIO env. var.): # < 0 - log only LM_INFO (4) and higher - default # otherwise all >= log all |
|
Failure counter for centralized logger (CL). If the failure counter reaches the limit, CL is disabled. |
|
Failure count limit.
|
|
Local output file, if Centralized Logger is unavailable (set by ACE_LOG_FILE env. var).
|
|
|
|
Reference to the persistent object which implements the Telecom Log Service�s Log interface, in particular the write_records method. |
|
Log entries whose priority exceeds (is greater than) the one specified with this property will be directly transmitted to the centralized logging, bypassing the local cache. If this is set to MinCachePriority 1, the local cache feature is disabled. |
|
Log entries whose priority is below (smaller than) the one specified with this property will be ignored (neither cached nor submitted to the centralized logging). In release version of the system, this will be set to LM_INFO (3), ignoring LM_TRACE and LM_DEBUG log entries. Debug version of the system will set this to LM_DEBUG (2). During development, it will be set to LM_TRACE (1). |
|
Reconnection retry (minimum time in sec).
|
|
Thread mutex to make log() method thread-safe |
|
Reference to the naming service. Used to get new reference of the Centralized Logger ("Log") in reconnectToLogger() method. |
|
|
|
Process |
|
Sending pending...
|
|
|
|
Syslog setting (set by ACE_LOG_SYSLOG env. var.): not defined - local file cache is used 'localhost' - local syslog is used (if available) hostname - remote syslog is used (by default port 514/udp is used). |
|
Thread creation flag.
|
|
Thread shutdown barrier.
|
|
Set /clear flag counter - number of timest that global flags were set cleared |
|
|
|
Thread specific storage |