ACE
6.3.3
|
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>
Public Member Functions | |
ACE_Logging_Strategy (void) | |
Constructor. More... | |
~ACE_Logging_Strategy (void) | |
Destructor. More... | |
virtual int | init (int argc, ACE_TCHAR *argv[]) |
Dynamic linking initialization hook. More... | |
virtual int | fini (void) |
Dynamic linking termination hook. More... | |
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_Reactor * | reactor (void) const |
Get the event demultiplexors. More... | |
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. More... | |
virtual | ~ACE_Service_Object (void) |
Destructor. More... | |
virtual int | suspend (void) |
Temporarily disable a service without removing it completely. More... | |
virtual int | resume (void) |
Re-enable a previously suspended service. More... | |
Public Member Functions inherited from ACE_Event_Handler | |
virtual | ~ACE_Event_Handler (void) |
Destructor is virtual to enable proper cleanup. More... | |
virtual ACE_HANDLE | get_handle (void) const |
Get the I/O handle. More... | |
virtual void | set_handle (ACE_HANDLE) |
Set the I/O handle. More... | |
virtual int | priority (void) const |
virtual void | priority (int priority) |
Set the priority of the Event_Handler. More... | |
virtual int | handle_input (ACE_HANDLE fd=ACE_INVALID_HANDLE) |
Called when input events occur (e.g., connection or data). More... | |
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). More... | |
virtual int | handle_exit (ACE_Process *) |
Called when a process exits. More... | |
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. More... | |
virtual Reference_Count | add_reference (void) |
Increment reference count on the handler. More... | |
virtual Reference_Count | remove_reference (void) |
Decrement reference count on the handler. More... | |
Reference_Counting_Policy & | reference_counting_policy (void) |
Current Reference_Counting_Policy. More... | |
Public Member Functions inherited from ACE_Shared_Object | |
ACE_Shared_Object (void) | |
Constructor. More... | |
virtual | ~ACE_Shared_Object (void) |
Destructor. More... | |
virtual int | info (ACE_TCHAR **info_string, size_t length=0) const |
Returns information on a service object. More... | |
Protected Member Functions | |
void | tokenize (ACE_TCHAR *flag_string) |
Tokenize to set all the flags. More... | |
void | priorities (ACE_TCHAR *priority_string, ACE_Log_Msg::MASK_TYPE mask) |
Tokenize to set priorities (either process or thread one). More... | |
Protected Member Functions inherited from ACE_Event_Handler | |
ACE_Event_Handler (ACE_Reactor *=0, int priority=ACE_Event_Handler::LO_PRIORITY) | |
Force ACE_Event_Handler to be an abstract base class. More... | |
Protected Attributes | |
u_long | thread_priority_mask_ |
Current thread's priority mask set by priorities . More... | |
u_long | process_priority_mask_ |
Process-wide priority mask set by priorities . More... | |
u_long | flags_ |
Flags we keep track of. More... | |
ACE_TCHAR * | filename_ |
File name we're logging to. More... | |
ACE_TCHAR * | logger_key_ |
Logger key for distributed logging. More... | |
ACE_TCHAR * | program_name_ |
Program name to be used for n format specifier. More... | |
bool | wipeout_logfile_ |
bool | fixed_number_ |
bool | order_files_ |
int | count_ |
int | max_file_number_ |
u_long | interval_ |
u_long | max_size_ |
ACE_Log_Msg * | log_msg_ |
ACE_Log_Msg instance to work with. More... | |
Protected Attributes inherited from ACE_Event_Handler | |
Atomic_Reference_Count | reference_count_ |
Reference count. More... | |
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. More... | |
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. More... | |
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. More... | |
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
sample_interval_in_secs | and -m |
max_size_in_KB | options 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
.
ACE_Logging_Strategy::ACE_Logging_Strategy | ( | void | ) |
Constructor.
ACE_Logging_Strategy::~ACE_Logging_Strategy | ( | void | ) |
Destructor.
|
virtual |
Dynamic linking termination hook.
Reimplemented from ACE_Shared_Object.
|
virtual |
This function helps to cancel timer events for this logging strategy in reactor during shutdown.
Reimplemented from ACE_Event_Handler.
|
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.
|
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.
|
protected |
Tokenize to set priorities (either process or thread one).
|
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.
|
virtual |
Get the event demultiplexors.
Reimplemented from ACE_Event_Handler.
|
protected |
Tokenize to set all the flags.
|
protected |
This tells us in what file we last wrote. It will be increased to enable multiple log files
|
protected |
File name we're logging to.
|
protected |
If true we have a maximum number of log files we can write. Default value is false, i.e., no maximum number.
|
protected |
Flags we keep track of.
|
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.
|
protected |
ACE_Log_Msg instance to work with.
|
protected |
Logger key for distributed logging.
|
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.
|
protected |
Maximum logfile size (in KB). Default value is ACE_DEFAULT_MAX_LOGFILE_SIZE.
|
protected |
If true we order the files as we rotate them. Default value is false, i.e., we do not rotate files by default.
|
protected |
Process-wide priority mask set by priorities
.
|
protected |
Program name to be used for n format specifier.
|
protected |
Current thread's priority mask set by priorities
.
|
protected |
If true then wipeout the logfile, otherwise append to it. Default value is false.