ACE  6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ACE_Logging_Strategy Class Reference

This class provides a way to dynamically configure the ACE logging mechanism at run time as well as enable the mechanisms for limiting log file size and log file backup/rotation capability. More...

#include <Logging_Strategy.h>

Inheritance diagram for ACE_Logging_Strategy:
Inheritance graph
[legend]
Collaboration diagram for ACE_Logging_Strategy:
Collaboration graph
[legend]

Public Member Functions

 ACE_Logging_Strategy (void)
 Constructor.
 
 ~ACE_Logging_Strategy (void)
 Destructor.
 
virtual int init (int argc, ACE_TCHAR *argv[])
 Dynamic linking initialization hook.
 
virtual int fini (void)
 Dynamic linking termination hook.
 
virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg)
 
virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask)
 
virtual void reactor (ACE_Reactor *r)
 
virtual ACE_Reactorreactor (void) const
 Get the event demultiplexors.
 
int parse_args (int argc, ACE_TCHAR *argv[])
 
void log_msg (ACE_Log_Msg *log_msg)
 
- Public Member Functions inherited from ACE_Service_Object
 ACE_Service_Object (ACE_Reactor *=0)
 Constructor.
 
virtual ~ACE_Service_Object (void)
 Destructor.
 
virtual int suspend (void)
 Temporarily disable a service without removing it completely.
 
virtual int resume (void)
 Re-enable a previously suspended service.
 
- Public Member Functions inherited from ACE_Event_Handler
virtual ~ACE_Event_Handler (void)
 Destructor is virtual to enable proper cleanup.
 
virtual ACE_HANDLE get_handle (void) const
 Get the I/O handle.
 
virtual void set_handle (ACE_HANDLE)
 Set the I/O handle.
 
virtual int priority (void) const
 
virtual void priority (int priority)
 Set the priority of the Event_Handler.
 
virtual int handle_input (ACE_HANDLE fd=ACE_INVALID_HANDLE)
 Called when input events occur (e.g., connection or data).
 
virtual int handle_output (ACE_HANDLE fd=ACE_INVALID_HANDLE)
 
virtual int handle_exception (ACE_HANDLE fd=ACE_INVALID_HANDLE)
 Called when an exceptional events occur (e.g., SIGURG).
 
virtual int handle_exit (ACE_Process *)
 Called when a process exits.
 
virtual int handle_signal (int signum, siginfo_t *=0, ucontext_t *=0)
 
virtual int resume_handler (void)
 
virtual int handle_qos (ACE_HANDLE=ACE_INVALID_HANDLE)
 
virtual int handle_group_qos (ACE_HANDLE=ACE_INVALID_HANDLE)
 
virtual
ACE_Reactor_Timer_Interface
reactor_timer_interface (void) const
 Get only the reactor's timer related interface.
 
virtual Reference_Count add_reference (void)
 Increment reference count on the handler.
 
virtual Reference_Count remove_reference (void)
 Decrement reference count on the handler.
 
Reference_Counting_Policyreference_counting_policy (void)
 Current Reference_Counting_Policy.
 
- Public Member Functions inherited from ACE_Shared_Object
 ACE_Shared_Object (void)
 Constructor.
 
virtual ~ACE_Shared_Object (void)
 Destructor.
 
virtual int info (ACE_TCHAR **info_string, size_t length=0) const
 Returns information on a service object.
 

Protected Member Functions

void tokenize (ACE_TCHAR *flag_string)
 Tokenize to set all the flags.
 
void priorities (ACE_TCHAR *priority_string, ACE_Log_Msg::MASK_TYPE mask)
 Tokenize to set priorities (either process or thread one).
 

Protected Attributes

u_long thread_priority_mask_
 Current thread's priority mask set by priorities.
 
u_long process_priority_mask_
 Process-wide priority mask set by priorities.
 
u_long flags_
 Flags we keep track of.
 
ACE_TCHARfilename_
 File name we're logging to.
 
ACE_TCHARlogger_key_
 Logger key for distributed logging.
 
ACE_TCHARprogram_name_
 Program name to be used for n format specifier.
 
bool wipeout_logfile_
 
bool fixed_number_
 
bool order_files_
 
int count_
 
int max_file_number_
 
u_long interval_
 
u_long max_size_
 
ACE_Log_Msglog_msg_
 ACE_Log_Msg instance to work with.
 

Additional Inherited Members

- Public Types inherited from ACE_Event_Handler
enum  {
  LO_PRIORITY = 0, HI_PRIORITY = 10, NULL_MASK = 0, READ_MASK = (1 << 0),
  WRITE_MASK = (1 << 1), EXCEPT_MASK = (1 << 2), ACCEPT_MASK = (1 << 3), CONNECT_MASK = (1 << 4),
  TIMER_MASK = (1 << 5), QOS_MASK = (1 << 6), GROUP_QOS_MASK = (1 << 7), SIGNAL_MASK = (1 << 8),
  ALL_EVENTS_MASK, RWE_MASK, DONT_CALL = (1 << 9)
}
 
enum  { ACE_EVENT_HANDLER_NOT_RESUMED = -1, ACE_REACTOR_RESUMES_HANDLER = 0, ACE_APPLICATION_RESUMES_HANDLER }
 
typedef long Reference_Count
 Reference count type.
 
- Static Public Member Functions inherited from ACE_Event_Handler
static ACE_THR_FUNC_RETURN read_adapter (void *event_handler)
 
static int register_stdin_handler (ACE_Event_Handler *eh, ACE_Reactor *reactor, ACE_Thread_Manager *thr_mgr, int flags=THR_DETACHED)
 
static int remove_stdin_handler (ACE_Reactor *reactor, ACE_Thread_Manager *thr_mgr)
 Performs the inverse of the register_stdin_handler() method.
 
- Protected Types inherited from ACE_Event_Handler
typedef ACE_Atomic_Op
< ACE_SYNCH_MUTEX,
Reference_Count
Atomic_Reference_Count
 Typedef for implementation of reference counting.
 

Detailed Description

This class provides a way to dynamically configure the ACE logging mechanism at run time as well as enable the mechanisms for limiting log file size and log file backup/rotation capability.

Depending upon when this service is invoked and with what flags, the output of other network services can be controlled. The output can be streamed to stderr, to a file, to a logging daemon, or it can be set to be "silent". If logging records are output to a file, the file can be set to a maximum size and repeatedly split into new files. The log file size can be limited at any logging point (i.e., application, client logging daemon, or server logging daemon) by specifying the -i

Parameters
sample_interval_in_secsand -m
max_size_in_KBoptions for the Logging_Strategy class in a svc.conf file.

By default, two logfiles are generated. It's possible, however, to generate as many logfiles as necessary to store all the information. To achieve this, it is only necessary to indicate the maximum size of the logfiles via the -m option and the process will generate automatically the logfiles. You can control the total number of logfiles created via the -n option.

By using the -o option we can also choose the mode of organization of the files, e.g., the first one is the normal used in Unix systems (when cron rotates the logs it keeps the lowest number the most recent one), the second is for increasing speed (we only create a new log file, and don't rotate the others (fewer accesses to disk)).

By default, the ACE_Logging_Strategy uses the singleton reactor, i.e., what's returned by ACE_Reactor::instance(). If you want to set the reactor used by ACE_Logging_Strategy to something other than the singleton reactor you'll need to get a pointer to the ACE_Logging_Strategy instance and do this

ACE_Reactor my_reactor; ACE_Logging_Strategy *logging_strategy = ...... // Get instance.

logging_strategy->reactor (&my_reactor);

and then logging_strategy will use your reactor. If you're dynamically linking the ACE_Logging_Strategy then you can use the ACE_Dynamic_Service template to get a pointer to the ACE_Logging_Strategy.

Constructor & Destructor Documentation

ACE_Logging_Strategy::ACE_Logging_Strategy ( void  )

Constructor.

ACE_Logging_Strategy::~ACE_Logging_Strategy ( void  )

Destructor.

Member Function Documentation

int ACE_Logging_Strategy::fini ( void  )
virtual

Dynamic linking termination hook.

Reimplemented from ACE_Shared_Object.

int ACE_Logging_Strategy::handle_close ( ACE_HANDLE  ,
ACE_Reactor_Mask   
)
virtual

This function helps to cancel timer events for this logging strategy in reactor during shutdown.

Reimplemented from ACE_Event_Handler.

int ACE_Logging_Strategy::handle_timeout ( const ACE_Time_Value tv,
const void *  arg 
)
virtual

Timeout handler which tests logfile size. If the current logfile size exceeds max_size_, the current logfile is closed, saved to logfile.old, and a new logfile is reopened.

Reimplemented from ACE_Event_Handler.

int ACE_Logging_Strategy::init ( int  argc,
ACE_TCHAR argv[] 
)
virtual

Dynamic linking initialization hook.

Reimplemented from ACE_Shared_Object.

void ACE_Logging_Strategy::log_msg ( ACE_Log_Msg log_msg)
int ACE_Logging_Strategy::parse_args ( int  argc,
ACE_TCHAR argv[] 
)

Parse arguments provided in svc.conf file.

  • '-f' Pass in the flags (such as OSTREAM, STDERR, LOGGER, VERBOSE, SILENT, VERBOSE_LITE) used to control logging.
  • '-i' The interval (in seconds) at which the logfile size is sampled (default is 0, i.e., do not sample by default).
  • '-k' Set the logging key.
  • '-m' Maximum logfile size in Kbytes.
  • '-n' Set the program name for the n format specifier.
  • '-N' The maximum number of logfiles that we want created.
  • '-o' Specifies that we want the no standard logfiles ordering (fastest processing in handle_timeout()). Default is not to order logfiles.
  • '-p' Pass in the process-wide priorities to either enable (e.g., DEBUG, INFO, WARNING, NOTICE, ERROR, CRITICAL, ALERT, EMERGENCY) or to disable (e.g., ~DEBUG, ~INFO, ~WARNING, ~NOTICE, ~ERROR, ~CRITICAL, ~ALERT, ~EMERGENCY).
  • '-s' Ensure that the OSTREAM flag is set and log to the filename.
  • '-t' Pass in the thread-wide priorities to either enable (e.g., DEBUG, INFO, WARNING, NOTICE, ERROR, CRITICAL, ALERT, EMERGENCY) or to disable (e.g., ~DEBUG, ~INFO, ~WARNING, ~NOTICE, ~ERROR, ~CRITICAL, ~ALERT, ~EMERGENCY).
  • '-w' Cause the logfile to be wiped out, both on startup and on reconfiguration.
void ACE_Logging_Strategy::priorities ( ACE_TCHAR priority_string,
ACE_Log_Msg::MASK_TYPE  mask 
)
protected

Tokenize to set priorities (either process or thread one).

void ACE_Logging_Strategy::reactor ( ACE_Reactor r)
virtual

Reactor accessors. If reactor changes then we need remove this event handler from previous reactor and scheduler for timer events in a new one.

Reimplemented from ACE_Event_Handler.

ACE_Reactor * ACE_Logging_Strategy::reactor ( void  ) const
virtual

Get the event demultiplexors.

Reimplemented from ACE_Event_Handler.

void ACE_Logging_Strategy::tokenize ( ACE_TCHAR flag_string)
protected

Tokenize to set all the flags.

Member Data Documentation

int ACE_Logging_Strategy::count_
protected

This tells us in what file we last wrote. It will be increased to enable multiple log files

ACE_TCHAR* ACE_Logging_Strategy::filename_
protected

File name we're logging to.

bool ACE_Logging_Strategy::fixed_number_
protected

If true we have a maximum number of log files we can write. Default value is false, i.e., no maximum number.

u_long ACE_Logging_Strategy::flags_
protected

Flags we keep track of.

u_long ACE_Logging_Strategy::interval_
protected

If non-zero, sampling interval (in secs) at which maximum logfile size is checked, otherwise logfile size can grow indefinitely. Default value is 0.

ACE_Log_Msg* ACE_Logging_Strategy::log_msg_
protected

ACE_Log_Msg instance to work with.

ACE_TCHAR* ACE_Logging_Strategy::logger_key_
protected

Logger key for distributed logging.

int ACE_Logging_Strategy::max_file_number_
protected

Tells us what is the maximum log file to write. We will write max_file_number_ + 1 files (includes the current log file). Default value is 1, i.e., 2 files by default.

u_long ACE_Logging_Strategy::max_size_
protected

Maximum logfile size (in KB). Default value is ACE_DEFAULT_MAX_LOGFILE_SIZE.

bool ACE_Logging_Strategy::order_files_
protected

If true we order the files as we rotate them. Default value is false, i.e., we do not rotate files by default.

u_long ACE_Logging_Strategy::process_priority_mask_
protected

Process-wide priority mask set by priorities.

ACE_TCHAR* ACE_Logging_Strategy::program_name_
protected

Program name to be used for n format specifier.

u_long ACE_Logging_Strategy::thread_priority_mask_
protected

Current thread's priority mask set by priorities.

bool ACE_Logging_Strategy::wipeout_logfile_
protected

If true then wipeout the logfile, otherwise append to it. Default value is false.


The documentation for this class was generated from the following files: