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

LoggingProxy Class Reference

#include <loggingLoggingProxy.h>

List of all members.

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 &timestamp, 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


Detailed Description

The Log Message Callback. All ACE logging requests (ACE_DEBUG, ACE_ERROR, or ACS_LOG calls) are to be redirected through this LoggingProxy. One of the first things what an ACS application should do is to initialize LoggingProxy. An example of initialization:
 // 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:

  1. ACS_LOG_STDOUT - variable which controls STDOUT output of logs (default is LM_INFO - 4). All priorities with >= priority are outputed. For instance, to have all logs outputted set variable to 0.
  2. ACS_LOG_SYSLOG - if variable is set, syslog is used to save logging cache (in case of unavailability of centralized logger). The syntax is [facility@]hostname[:port] (default facility is LOG_USER and default port is 514). To take advantage of local syslog calls (on systems supporting it), use "localhost" as hostname. If variable is not set, local file is used to save logs.
  3. ACS_LOG_FILE - the name of the file where logger cache is saved (default is /tmp/acs_local_log).
Author:
Matej Sekoranja, Jozef Stefan Institute, Slovenia
Version:
"@(#) $Id: loggingLoggingProxy.h,v 1.35 2008/08/05 15:46:07 bjeram Exp $"


Member Typedef Documentation

typedef std::deque<ACSLoggingLog::LogBinaryRecord *> LoggingProxy::LogBinDeque [private]
 

typedef std::deque<ACE_CString> LoggingProxy::LogDeque [private]
 

Local cache


Constructor & Destructor Documentation

LoggingProxy::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
 

Constructor WARNING: LoggingProxy MUST be created before calling any of its static methods!

LoggingProxy::~LoggingProxy  ) 
 

Destructor.


Member Function Documentation

void LoggingProxy::AddAttribute const ACE_TCHAR *  szName,
const ACE_TCHAR *  szValue
[static]
 

Add an attribute to the list of next log entries� attributes.

void LoggingProxy::AddData const ACE_TCHAR *  szName,
const ACE_TCHAR *  szFormat,
  ...
[static]
 

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.

const ACE_TCHAR* LoggingProxy::antenna  )  [static]
 

Return the antenna. The name is global per thread (stored in thread-specific storage TSS)

void LoggingProxy::antenna const ACE_TCHAR *  aud  )  [static]
 

Set the antenna where the log message was generated.

const ACE_TCHAR* LoggingProxy::array  )  [static]
 

Return the array. The name is global per thread (stored in thread-specific storage TSS)

void LoggingProxy::array const ACE_TCHAR *  aud  )  [static]
 

Set the array where the log message was generated.

const ACE_TCHAR* LoggingProxy::audience  )  [static]
 

Return the audience. The name is global per thread (stored in thread-specific storage TSS)

void LoggingProxy::audience const ACE_TCHAR *  aud  )  [static]
 

Set the audience intended for the log message.

std::string LoggingProxy::BinToXml ACSLoggingLog::LogBinaryRecord *  record  )  [static]
 

const ACE_TCHAR* LoggingProxy::Context  )  [static]
 

Retrieve the context in which the code is operating.

void LoggingProxy::Context const ACE_TCHAR *  szName  )  [static]
 

Set the context in which the code is operating. Pointer to the name must be stored in the thread-specific storage!

void LoggingProxy::done  )  [static]
 

returns ACE_LOG_MSG to default state

void LoggingProxy::failedToSend  )  [private]
 

Method to be called when CORBA invocation to the centralized logger failed.

void LoggingProxy::File const ACE_TCHAR *  fileName  )  [static]
 

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!

void LoggingProxy::Flags unsigned int  uiFlags  )  [static]
 

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.

void LoggingProxy::flush  ) 
 

Forces logger to flush cache. Thread safe!

void LoggingProxy::formatISO8601inUTC const ACE_Time_Value &  timestamp,
ACE_TCHAR  str[]
[static, private]
 

Get time in ISO8601 format in UTC (eg. 2000-12-31T08:12:21.322) - 24 chars (incl. ).

int LoggingProxy::getCacheLogCount  )  const [inline]
 

For testing only (not tread-safe).

unsigned long LoggingProxy::getPriority ACE_Log_Record &  log_record  )  [static]
 

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!

const ACE_TCHAR* LoggingProxy::host  )  [static]
 

Return the host The name is global per thread (stored in thread-specific storage TSS)

void LoggingProxy::host const ACE_TCHAR *  aud  )  [static]
 

Set the host where the log message was generated.

void LoggingProxy::init LoggingProxy loggingProxy  )  [static]
 

initializes ACE_LOG_MSG (must be done per each thread)

bool LoggingProxy::isInit  )  [inline, static]
 

Returns true if loggin is initialized otherwise false.

bool LoggingProxy::isInitThread  )  [static]
 

Returns true if logging is initialized in this thread.

void LoggingProxy::Line long  lineNumber  )  [static]
 

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!

void LoggingProxy::log ACE_Log_Record &  log_record  ) 
 

Receives all log entries submited within the process. Thread safe!

void LoggingProxy::LogEntryType const ACE_TCHAR *  szType  )  [static]
 

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!

void LoggingProxy::LogId const ACE_TCHAR *  szName  )  [static]
 

Specify the LogId attribute of the log entry that follows. Can be 0 (default) in which case no LogId attribute is output.

const int LoggingProxy::LogLevelLocalType  )  [static]
 

void LoggingProxy::LogLevelLocalType int  logLevelLocalType  )  [static]
 

const int LoggingProxy::LogLevelRemoteType  )  [static]
 

void LoggingProxy::LogLevelRemoteType int  logLevelRemoteType  )  [static]
 

void LoggingProxy::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!

const int LoggingProxy::PrivateFlags  )  [static]
 

Private flags (to be used only internally).

void LoggingProxy::PrivateFlags int  privateFlags  )  [static]
 

Private flags (to be used only internally).

const ACE_TCHAR* LoggingProxy::ProcessName  )  [static]
 

Returns the name of the process.

void LoggingProxy::ProcessName const ACE_TCHAR *  szName  )  [static]
 

Specifies the name of the process. Must be stored in a process-wide global variable!

bool LoggingProxy::reconnectToLogger  )  [private]
 

Tries to reconnect to the centralized logger (after some amount of time) and return <true> if successful.

void LoggingProxy::ResetAttributes  )  [static]
 

Reset the list of custom attributes. The attributes are applicable to the next log entry only.

void LoggingProxy::Routine const ACE_TCHAR *  szRoutine  )  [static]
 

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!

void LoggingProxy::sendBinLogs ACE_Log_Record &  log_record,
const ACE_TCHAR *  timestamp,
const ACE_TCHAR *  entryType
[private]
 

void LoggingProxy::sendCache  )  [private]
 

Send local cache file to the centralized logger (Telecom log service).

void LoggingProxy::sendCacheInternal  )  [private]
 

Send local cache file to the centralized logger (Telecom log service).

bool LoggingProxy::sendRecord CORBA::Any &  record  )  [private]
 

Send given record to the centralized logger (Telecom log service) Return: true if successful, false on failure

void LoggingProxy::sendXmlLogs ACE_Log_Record &  log_record,
const ACE_TCHAR *  timestamp,
const ACE_TCHAR *  entryType
[private]
 

void LoggingProxy::setCentralizedLogger DsLogAdmin::Log_ptr  centralizedLogger  ) 
 

Set Centralized Logger.

void LoggingProxy::setNamingContext CosNaming::NamingContext_ptr  namingContext  )  [inline]
 

Set Naming Context.

void LoggingProxy::setStdio int  stdio  )  [inline]
 

Sets ACS_LOG_STDOUT runtime.

const ACE_TCHAR* LoggingProxy::SourceObject  )  [static]
 

Return the name of the source object set by SourceObject The name is global per thread (stored in thread-specific storage TSS)

void LoggingProxy::SourceObject const ACE_TCHAR *  soName  )  [static]
 

Set the name of the object which is publishing the log. Pointer to the name must be stored in the thread-specific storage!

const ACE_TCHAR* LoggingProxy::StackId  )  [static]
 

Returns the the logical thread ID. Must have been set previously using StackId.

void LoggingProxy::StackId const ACE_TCHAR *  szId  )  [static]
 

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.

int LoggingProxy::StackLevel  )  [static]
 

Retrieve the stack level in the current logical thread.

void LoggingProxy::StackLevel int  nLevel  )  [static]
 

Set the stack level in the current logical thread. The value must be stored in the thread-specific storage!

void LoggingProxy::successfullySent  )  [private]
 

Method to be called when CORBA invocation to the centralized logger was successful.

virtual int LoggingProxy::svc  )  [private, virtual]
 

Thread entry point (thread worker).

const ACE_TCHAR* LoggingProxy::ThreadName  )  [static]
 

Returns the name of the thread.

void LoggingProxy::ThreadName const ACE_TCHAR *  szName  )  [static]
 

Specifies the name of the thread. Pointer to the name must be stored in the thread-specific storage!

void LoggingProxy::URI const ACE_TCHAR *  szName  )  [static]
 

Specify the URI attribute of the log entry that follows. Can be 0 (default) in which case no URI attribute is output.

void* LoggingProxy::worker void *   )  [static, private]
 

Static thread worker (calls svc).


Member Data Documentation

bool LoggingProxy::initialized [static, private]
 

Initialization flag.

int LoggingProxy::instances [static, private]
 

bool LoggingProxy::m_alreadyInformed [private]
 

Switch to inform client only once about logging to the file.

unsigned int LoggingProxy::m_autoFlushTimeoutSec [private]
 

Timeout in seconds to auto-flush (send cache).

LogBinDeque LoggingProxy::m_bin_cache [private]
 

LogDeque LoggingProxy::m_cache [private]
 

bool LoggingProxy::m_cacheDisabled [private]
 

Cache state.

unsigned long LoggingProxy::m_cacheSize [private]
 

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.

ACE_Time_Value LoggingProxy::m_disconnectionTime [private]
 

The time CL was disabled. LoggingProxy will try to reconnect after some (defined) time.

ACE_SYNCH_CONDITION LoggingProxy::m_doWorkCond [private]
 

Work condition.

ACE_SYNCH_MUTEX LoggingProxy::m_doWorkMutex [private]
 

The mutual exclusion mechanism which is required to use the <m_workworkcond>.

int LoggingProxy::m_envCentralizePriority [private]
 

int LoggingProxy::m_envStdioPriority [private]
 

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

int LoggingProxy::m_failureCount [private]
 

Failure counter for centralized logger (CL). If the failure counter reaches the limit, CL is disabled.

int LoggingProxy::m_failureLimit [static, private]
 

Failure count limit.

ACE_CString LoggingProxy::m_filename [private]
 

Local output file, if Centralized Logger is unavailable (set by ACE_LOG_FILE env. var).

bool LoggingProxy::m_logBin [private]
 

DsLogAdmin::Log_var LoggingProxy::m_logger [private]
 

Reference to the persistent object which implements the Telecom Log Service�s Log interface, in particular the write_records method.

unsigned long LoggingProxy::m_maxCachePriority [private]
 

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.

unsigned long LoggingProxy::m_minCachePriority [private]
 

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).

int LoggingProxy::m_minReconnectionTime [static, private]
 

Reconnection retry (minimum time in sec).

ACE_Recursive_Thread_Mutex LoggingProxy::m_mutex [private]
 

Thread mutex to make log() method thread-safe

CosNaming::NamingContext_var LoggingProxy::m_namingContext [private]
 

Reference to the naming service. Used to get new reference of the Centralized Logger ("Log") in reconnectToLogger() method.

bool LoggingProxy::m_noLogger [private]
 

char LoggingProxy::m_process[256] [static, private]
 

Process

volatile bool LoggingProxy::m_sendingPending [private]
 

Sending pending...

volatile bool LoggingProxy::m_shutdown [private]
 

ACE_CString LoggingProxy::m_syslog [private]
 

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).

volatile bool LoggingProxy::m_threadCreated [private]
 

Thread creation flag.

ACE_Barrier LoggingProxy::m_threadShutdown [private]
 

Thread shutdown barrier.

unsigned int LoggingProxy::setClrCount_m [static, private]
 

Set /clear flag counter - number of timest that global flags were set cleared

ACE_CString LoggingProxy::sourceObject_m [static, private]
 

ACE_TSS<LoggingTSSStorage>* LoggingProxy::tss [static, private]
 

Thread specific storage


The documentation for this class was generated from the following file:
Generated on Thu Apr 30 02:36:33 2009 for ACS C++ API by doxygen 1.3.8