Log4gFilter

Log4gFilter — Log event filter base class

Synopsis

                    Log4gFilter;
                    Log4gFilterClass;
enum                Log4gFilterDecision;
Log4gFilterDecision  log4g_filter_decide                (Log4gFilter *self,
                                                         Log4gLoggingEvent *event);
void                log4g_filter_activate_options       (Log4gFilter *self);
Log4gFilter *       log4g_filter_get_next               (Log4gFilter *self);
void                log4g_filter_set_next               (Log4gFilter *self,
                                                         Log4gFilter *next);
Log4gFilterDecision  (*Log4gFilterDecide)               (Log4gFilter *self,
                                                         Log4gLoggingEvent *event);
void                (*Log4gFilterActivateOptions)       (Log4gFilter *self);

Description

Users may extend this class to implement custom log event filtering. Note that Log4gLogger & Log4gAppenderSkeleton (the parent of all standard appenders) have builtin filter rules. You should understand and use the builtin rules before writing custom filters.

Filters are organized in a linear chain. Log4gAppenderSkeleton calls the decide() function of each filter sequentially in order to determine the outcome of the filtering process.

Sub-classes must override the decide() virtual function. This function must return one of the integer constants LOG4G_FILTER_DENY, LOG4G_FILTER_NEUTRAL, or LOG4G_FILTER_ACCEPT.

If the value LOG4G_FILTER_DENY is returned the log event is dropped immediately without consulting the remaining filters.

If the value LOG4G_FILTER_NEUTRAL is returned the remaining filters in the chain are consulted. If the final filter returns LOG4G_FILTER_NEUTRAL then the log event is logged. If no filters exist then all messages are logged.

If the value LOG4G_FILTER_ACCEPT is returned the the log event is logged immediately without consulting the remaining filters.

Details

Log4gFilter

typedef struct {
} Log4gFilter;

The Log4gFilter structure does not have any public members.


Log4gFilterClass

typedef struct {
    Log4gFilterDecide decide;
    Log4gFilterActivateOptions activate_options;
} Log4gFilterClass;

Log4gFilterDecide decide;

Implements the filter decision.

Log4gFilterActivateOptions activate_options;

Activate all options set for this filter.

enum Log4gFilterDecision

typedef enum {
    LOG4G_FILTER_ACCEPT = 1,
    LOG4G_FILTER_NEUTRAL = 0,
    LOG4G_FILTER_DENY = -1
} Log4gFilterDecision;

LOG4G_FILTER_ACCEPT

The log event must be logged immediately. The remaining filters (if any) should not be consulted.

LOG4G_FILTER_NEUTRAL

This filter is neutral regarding the event. The remaining filters (if any) should be consulted for a final decision.

LOG4G_FILTER_DENY

The log event must dropped immediately. The remaining filters (if any) should not be consulted.

log4g_filter_decide ()

Log4gFilterDecision  log4g_filter_decide                (Log4gFilter *self,
                                                         Log4gLoggingEvent *event);

Calls the decide function from the Log4gFilterClass of self.

self :

A Log4gFilter object.

event :

A logging event.

Returns :

A filter decision based upon the logging event.

Since 0.1


log4g_filter_activate_options ()

void                log4g_filter_activate_options       (Log4gFilter *self);

Calls the activate_options function from the Log4gFilterClass of self.

Filters generally need to have their options activated before they can be used. This class provides a do-nothing implementation for convenience.

self :

A Log4gFilter object.

Since 0.1


log4g_filter_get_next ()

Log4gFilter *       log4g_filter_get_next               (Log4gFilter *self);

Retrieve the next filter in the chain.

Filters are chained together. This function returns the next filter in the chain, or NULL if there are no more.

self :

A Log4gFilter object.

Returns :

The next filter in the chain, or \e NULL if there are no more.

Since 0.1


log4g_filter_set_next ()

void                log4g_filter_set_next               (Log4gFilter *self,
                                                         Log4gFilter *next);

Set the next filter in the chain.

Filters are chained together. This function sets the filter that will follow this one in the chain.

self :

A filter object.

next :

The filter to set as the next in the chain.

Since 0.1


Log4gFilterDecide ()

Log4gFilterDecision  (*Log4gFilterDecide)               (Log4gFilter *self,
                                                         Log4gLoggingEvent *event);

If the decision is LOG4G_FILTER_DENY, the even will be dropped. If the decision is LOG4G_FILTER_ACCEPT, then any remaining filters will be invoked. If the decision is LOG4G_FILTER_ACCEPT the event will be logged without consulting any other filters in the chain.

self :

A Log4gFilter object.

event :

A logging event.

Returns :

A filter decision based upon the logging event.

Since 0.1


Log4gFilterActivateOptions ()

void                (*Log4gFilterActivateOptions)       (Log4gFilter *self);

Activate all options set for this filter.

self :

A Log4gFilter object.

Since 0.1