stumpless 2.2.0
|
A target allowing entries to be sent to a custom function. More...
#include <FunctionTarget.hpp>
Public Member Functions | |
FunctionTarget (struct stumpless_target *equivalent) | |
FunctionTarget (const char *name, stumpless_log_func_t log_function) | |
Creates a new target with the given function. | |
~FunctionTarget (void) | |
Closes this target and releases all memory and other resources held by it. | |
const char * | GetDefaultAppName (void) |
Returns the default app name used by this target. | |
const char * | GetDefaultMsgid (void) |
Returns the default msgid used by this target. | |
Facility | GetDefaultFacility (void) |
Gets the default facility of this target. | |
stumpless_filter_func_t | GetFilter (void) |
Returns the current filter used by this target to determine if entries should be allowed through it. | |
int | GetMask (void) |
Gets the log mask of this target. | |
const char * | GetName (void) |
Returns the name of this target. | |
int | GetOption (int option) |
Gets the given option for this target. | |
bool | IsOpen (void) |
Checks to see if this target is open. | |
FunctionTarget & | Log (const char *message,...) |
Writes a string message to this target. | |
FunctionTarget & | Log (int priority, const char *message,...) |
Writes a log message with the given priority to this target. | |
FunctionTarget & | Log (Facility facility, Severity severity, const char *message,...) |
Writes a log message with the given facility and severity to this target. | |
FunctionTarget & | Log (Entry entry) |
Writes an Entry to this target. | |
void | Open (void) |
Opens this target if it has been paused. | |
FunctionTarget & | SetDefaultAppName (const char *app_name) |
Sets the default app name for this target. | |
FunctionTarget & | SetDefaultFacility (int facility) |
Sets the default facility of the target. | |
FunctionTarget & | SetDefaultMsgid (const char *msgid) |
Sets the default message id for this target. | |
FunctionTarget & | SetFilter (stumpless_filter_func_t filter) |
Sets the filter used by this target to determine whether entries should be logged to it. | |
FunctionTarget & | SetMask (int mask) |
Sets the log mask of a target. | |
FunctionTarget & | SetOption (int option) |
Sets an option on a target. | |
FunctionTarget & | UnsetOption (int option) |
Unsets an option on a target. | |
Public Attributes | |
struct stumpless_target * | equivalent |
A target allowing entries to be sent to a custom function.
Function targets provide a way to fully customize the behavior of a target, defining any desired functionality and directly providing it to the target. This can be used as a way to implement custom log targets such as a specialized database table, or to take action if specific event types are sent to the target.
stumpless::FunctionTarget::FunctionTarget | ( | struct stumpless_target * | equivalent | ) |
stumpless::FunctionTarget::FunctionTarget | ( | const char * | name, |
stumpless_log_func_t | log_function ) |
Creates a new target with the given function.
name | The name of this target. |
log_function | The function to use to log entries sent to the target. This function will be called for each entry sent to the target, and will be given a pointer to the target itself as well as the entry passed to it. It returns an int where a non-negative value indicates success and a negative value is returned in the event of an error. The target and entry pointers passed to the function are guaranteed to be non-NULL, since NULL pointers will generate errors before the function is called. |
stumpless::FunctionTarget::~FunctionTarget | ( | void | ) |
Closes this target and releases all memory and other resources held by it.
const char * stumpless::FunctionTarget::GetDefaultAppName | ( | void | ) |
Returns the default app name used by this target.
The returned character buffer must be freed by the caller when it is no longer needed to avoid memory leaks. Available since release v2.0.0.
Facility stumpless::FunctionTarget::GetDefaultFacility | ( | void | ) |
Gets the default facility of this target.
const char * stumpless::FunctionTarget::GetDefaultMsgid | ( | void | ) |
Returns the default msgid used by this target.
The returned character buffer must be freed by the caller when it is no longer needed to avoid memory leaks. Available since release v2.0.0.
stumpless_filter_func_t stumpless::FunctionTarget::GetFilter | ( | void | ) |
Returns the current filter used by this target to determine if entries should be allowed through it.
Note that NULL is a valid return value from this function, indicating that the target does not currently have a filter set. Available since release v2.1.0.
int stumpless::FunctionTarget::GetMask | ( | void | ) |
Gets the log mask of this target.
The mask is a bit field of severities that this target will allow if the default mask-based filter is in use. These can be formed and checked using the STUMPLESS_SEVERITY_MASK and STUMPLESS_SEVERITY_MASK_UPTO macros, and combining them using bitwise or operations. Available since release v2.1.0.
const char * stumpless::FunctionTarget::GetName | ( | void | ) |
Returns the name of this target.
The returned character buffer must be freed by the caller when it is no longer needed to avoid memory leaks. Available since release v2.0.0.
int stumpless::FunctionTarget::GetOption | ( | int | option | ) |
Gets the given option for this target.
While the returned value is the option if it is set, callers can also simply use the truth value of the return to see if the provided option is set.
option | The option to check this target for. |
bool stumpless::FunctionTarget::IsOpen | ( | void | ) |
Checks to see if this target is open.
FunctionTarget & stumpless::FunctionTarget::Log | ( | const char * | message, |
... ) |
Writes a string message to this target.
message | The message to log, optionally containing any format specifiers valid in printf. This may be NULL, in which case an event with no message is logged. |
... | Substitutions for any format specifiers provided in message. The number of substitutions provided must exactly match the number of specifiers given. |
FunctionTarget & stumpless::FunctionTarget::Log | ( | Entry | entry | ) |
FunctionTarget & stumpless::FunctionTarget::Log | ( | Facility | facility, |
Severity | severity, | ||
const char * | message, | ||
... ) |
Writes a log message with the given facility and severity to this target.
facility | The facility code of the message. |
severity | The severity code of the message. |
message | The message to log, optionally containing any format specifiers valid in printf. |
... | Substitutions for any format specifiers provided in message. The number of substitutions provided must exactly match the number of specifiers given. |
FunctionTarget & stumpless::FunctionTarget::Log | ( | int | priority, |
const char * | message, | ||
... ) |
Writes a log message with the given priority to this target.
priority | The priority of the message, described in RFC 5424 as the PRIVAL. This should be the bitwise or of the integer values of a Facility and a Severity. |
message | The message to log, optionally containing any format specifiers valid in printf. |
... | Substitutions for any format specifiers provided in message. The number of substitutions provided must exactly match the number of specifiers given. |
void stumpless::FunctionTarget::Open | ( | void | ) |
Opens this target if it has been paused.
FunctionTarget & stumpless::FunctionTarget::SetDefaultAppName | ( | const char * | app_name | ) |
Sets the default app name for this target.
app_name | The new default app name, as a NULL-terminated string. |
FunctionTarget & stumpless::FunctionTarget::SetDefaultFacility | ( | int | facility | ) |
Sets the default facility of the target.
facility | The default facility for the target to use. This should be a STUMPLESS_FACILITY value. |
FunctionTarget & stumpless::FunctionTarget::SetDefaultMsgid | ( | const char * | msgid | ) |
Sets the default message id for this target.
msgid | The new default message id, as a NULL-terminated string. |
FunctionTarget & stumpless::FunctionTarget::SetFilter | ( | stumpless_filter_func_t | filter | ) |
Sets the filter used by this target to determine whether entries should be logged to it.
Available since release v2.1.0.
filter | The new filter to use for this target. |
FunctionTarget & stumpless::FunctionTarget::SetMask | ( | int | mask | ) |
Sets the log mask of a target.
The mask is a bit field of severities that this target will allow if the default mask-based filter is in use. These can be formed and checked using the STUMPLESS_SEVERITY_MASK and STUMPLESS_SEVERITY_MASK_UPTO macros, and combining them using bitwise or operations. Available since release v2.1.0.
mask | The new mask to use for this target. |
FunctionTarget & stumpless::FunctionTarget::SetOption | ( | int | option | ) |
Sets an option on a target.
option | The option to set. This should be a STUMPLESS_OPTION value. |
FunctionTarget & stumpless::FunctionTarget::UnsetOption | ( | int | option | ) |
Unsets an option on a target.
option | The option to unset. This should be a STUMPLESS_OPTION value. |
struct stumpless_target* stumpless::FunctionTarget::equivalent |