stumpless 2.2.0
Loading...
Searching...
No Matches
chain.h File Reference

Chains allow logs to be sent to a group of targets. More...

Go to the source code of this file.

Functions

STUMPLESS_PUBLIC_FUNCTION struct stumpless_targetstumpless_add_target_to_chain (struct stumpless_target *chain, struct stumpless_target *target)
 Adds a target to an existing chain target.
 
STUMPLESS_PUBLIC_FUNCTION void stumpless_close_chain_and_contents (struct stumpless_target *chain)
 Closes a chain of targets.
 
STUMPLESS_PUBLIC_FUNCTION void stumpless_close_chain_only (struct stumpless_target *chain)
 Closes a chain target.
 
STUMPLESS_PUBLIC_FUNCTION size_t stumpless_get_chain_length (const struct stumpless_target *chain)
 Gets the number of targets currently in a chain.
 
STUMPLESS_PUBLIC_FUNCTION struct stumpless_targetstumpless_new_chain (const char *name)
 Creates a new target chain.
 

Detailed Description

Chains allow logs to be sent to a group of targets.

Since
release v2.2.0

Thread Safety: MT-Safe Logging to chains is thread safe. A lock is used to prevent changes to the chain during a logging operation. Note that the thread safety of each target in the chain must also be considered when determining the thread safety of an operation on a chain.

Async Signal Safety: AS-Unsafe lock Logging to chains is not signal safe, as a non-reentrant lock is used to coordinate changes to the chain.

Async Cancel Safety: AC-Unsafe lock Logging to chains is not safe to call from threads that may be asynchronously cancelled, as the cleanup of the lock may not be completed.

Function Documentation

◆ stumpless_add_target_to_chain()

STUMPLESS_PUBLIC_FUNCTION struct stumpless_target * stumpless_add_target_to_chain ( struct stumpless_target * chain,
struct stumpless_target * target )

Adds a target to an existing chain target.

Thread Safety: MT-Safe This function is thread safe.

Async Signal Safety: AS-Unsafe lock heap This function is not safe to call from signal handlers due to the use of a non-reentrant lock as well as the use of memory allocation functions when the static target array is not big enough. If the chain has space for the new target in its static array, then the heap constraint is not present.

Async Cancel Safety: AC-Unsafe lock heap This function is not safe to call from threads that may be asynchronously cancelled, as the lock may not be released, and the memory allocation functions may not be AC-Safe. If the chain has space for the new target in its static array, then the heap constraint is not present.

Since
release v2.2.0
Parameters
chainThe chain target to add the target to.
targetThe new target to add to the chain.
Returns
The chain target if no error is encountered. In the event of an error, NULL is returned and an error code is set appropriately.
Examples
chain_example.c.

◆ stumpless_close_chain_and_contents()

STUMPLESS_PUBLIC_FUNCTION void stumpless_close_chain_and_contents ( struct stumpless_target * chain)

Closes a chain of targets.

This function closes each target in the chain, and then destroys all memory allocated for the chain itself.

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 lock heap This function is not safe to call from signal handlers due to the destruction of a lock that may be in use as well as the use of the memory deallocation function to release memory.

Async Cancel Safety: AC-Unsafe lock heap This function is not safe to call from threads that may be asynchronously cancelled, as the cleanup of the lock may not be completed, and the memory deallocation function may not be AC-Safe itself.

Since
release v2.2.0
Parameters
chainThe chain of targets to close.
Examples
chain_example.c.

◆ stumpless_close_chain_only()

STUMPLESS_PUBLIC_FUNCTION void stumpless_close_chain_only ( struct stumpless_target * chain)

Closes a chain target.

This function destroys all memory allocated for the chain itself. The targets in the chain are not closed or modified.

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 lock heap This function is not safe to call from signal handlers due to the destruction of a lock that may be in use as well as the use of the memory deallocation function to release memory.

Async Cancel Safety: AC-Unsafe lock heap This function is not safe to call from threads that may be asynchronously cancelled, as the cleanup of the lock may not be completed, and the memory deallocation function may not be AC-Safe itself.

Since
release v2.2.0
Parameters
chainThe chain to close.

◆ stumpless_get_chain_length()

STUMPLESS_PUBLIC_FUNCTION size_t stumpless_get_chain_length ( const struct stumpless_target * chain)

Gets the number of targets currently in a chain.

Thread Safety: MT-Safe This function is thread safe.

Async Signal Safety: AS-Unsafe lock This function is not safe to call from signal handlers due to the use of a non-reentrant lock.

Async Cancel Safety: AC-Unsafe lock This function is not safe to call from threads that may be asynchronously cancelled, as the lock may not be released.

Since
release v2.2.0
Parameters
chainThe chain to get the length of.
Returns
The length of the provided chain if no error is encountered. If an error is encountered, 0 is returned and an error code is set appropriately.

◆ stumpless_new_chain()

STUMPLESS_PUBLIC_FUNCTION struct stumpless_target * stumpless_new_chain ( const char * name)

Creates a new target chain.

Thread Safety: MT-Safe This function is thread safe.

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.

Since
release v2.2.0
Parameters
nameThe name of the logging target, as well as the name of the file to open.
Returns
The new chain if no error is encountered. In the event of an error, NULL is returned and an error code is set appropriately.
Examples
chain_example.c.