stumpless 2.2.0
|
Function targets allow log entries to be sent to a custom function, making it possible to implement arbitrary functionality using this library as a logging framework. More...
Go to the source code of this file.
Typedefs | |
typedef int(* | stumpless_log_func_t) (const struct stumpless_target *, const struct stumpless_entry *) |
A handler for entries sent to a function target. | |
Functions | |
STUMPLESS_PUBLIC_FUNCTION void | stumpless_close_function_target (const struct stumpless_target *target) |
Closes a function target. | |
STUMPLESS_PUBLIC_FUNCTION struct stumpless_target * | stumpless_open_function_target (const char *name, stumpless_log_func_t log_function) |
Opens a function target. | |
Function targets allow log entries to be sent to a custom function, making it possible to implement arbitrary functionality using this library as a logging framework.
If a log function returns a negative value, it is passed on as the result of the library call, and a STUMPLESS_FUNCTION_TARGET_FAILURE error is raised. This allows error handling to use either return codes or the stumpless error types.
Thread Safety: MT-Safe Logging to function targets is thread safe, dependent on the thread safety of the function itself. No coordination is done by stumpless itself to ensure that calls to the function are serialized.
Async Signal Safety: AS-Safe Logging to function targets is signal safe, depndent on the signal safety of the function itself.
Async Cancel Safety: AC-Safe Logging to function targets is safe to call from threads that may be asynchronously cancelled, dependent on the cancellation safety of the function itself.
typedef int(* stumpless_log_func_t) (const struct stumpless_target *, const struct stumpless_entry *) |
A handler for entries sent to a function target.
STUMPLESS_PUBLIC_FUNCTION void stumpless_close_function_target | ( | const struct stumpless_target * | target | ) |
Closes a function target.
Thread Safety: MT-Unsafe This function is not thread safe as it destroys resources that other threads would use if they tried to reference this target.
Async Signal Safety: AS-Unsafe heap This function is not safe to call from signal handlers due to the use of the memory deallocation function to release memory.
Async Cancel Safety: AC-Unsafe heap This function is not safe to call from threads that may be asynchronously cancelled, as the memory deallocation function may not be AC-Safe itself.
target | The function target to close. |
STUMPLESS_PUBLIC_FUNCTION struct stumpless_target * stumpless_open_function_target | ( | const char * | name, |
stumpless_log_func_t | log_function ) |
Opens a function target.
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.
Thread Safety: MT-Safe race:name This function is thread safe, of course assuming that name is not modified by any other threads during execution.
Async Signal Safety: AS-Unsafe heap This function is not safe to call from signal handlers due to the use of memory allocation functions.
Async Cancel Safety: AC-Unsafe heap This function is not safe to call from threads that may be asynchronously cancelled, as the memory allocation function may not be AC-Safe itself.
name | The name of the logging 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 with the same semantics as stumpless_add_entry 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. |