27#ifndef __STUMPLESS_TARGET_H
28#define __STUMPLESS_TARGET_H
34#include <stumpless/config.h>
40#define STUMPLESS_DEFAULT_TARGET_NAME "stumpless-default"
47#define STUMPLESS_BUFFER_TARGET_VALUE 0
50#define STUMPLESS_FILE_TARGET_VALUE 1
53#define STUMPLESS_FUNCTION_TARGET_VALUE 2
56#define STUMPLESS_JOURNALD_TARGET_VALUE 3
59#define STUMPLESS_NETWORK_TARGET_VALUE 4
62#define STUMPLESS_SOCKET_TARGET_VALUE 5
65#define STUMPLESS_STREAM_TARGET_VALUE 6
68#define STUMPLESS_WINDOWS_EVENT_LOG_TARGET_VALUE 7
71#define STUMPLESS_SQLITE3_TARGET_VALUE 8
78#define STUMPLESS_CHAIN_TARGET_VALUE 9
86#define STUMPLESS_FOREACH_TARGET_TYPE( ACTION )\
87ACTION( STUMPLESS_BUFFER_TARGET, STUMPLESS_BUFFER_TARGET_VALUE )\
88ACTION( STUMPLESS_FILE_TARGET, STUMPLESS_FILE_TARGET_VALUE )\
89ACTION( STUMPLESS_FUNCTION_TARGET, STUMPLESS_FUNCTION_TARGET_VALUE )\
90ACTION( STUMPLESS_JOURNALD_TARGET, STUMPLESS_JOURNALD_TARGET_VALUE )\
91ACTION( STUMPLESS_NETWORK_TARGET, STUMPLESS_NETWORK_TARGET_VALUE )\
92ACTION( STUMPLESS_SOCKET_TARGET, STUMPLESS_SOCKET_TARGET_VALUE )\
93ACTION( STUMPLESS_STREAM_TARGET, STUMPLESS_STREAM_TARGET_VALUE )\
94ACTION( STUMPLESS_WINDOWS_EVENT_LOG_TARGET, STUMPLESS_WINDOWS_EVENT_LOG_TARGET_VALUE )\
95ACTION( STUMPLESS_SQLITE3_TARGET, STUMPLESS_SQLITE3_TARGET_VALUE )\
96ACTION( STUMPLESS_CHAIN_TARGET, STUMPLESS_CHAIN_TARGET_VALUE )
191#ifdef STUMPLESS_THREAD_SAFETY_SUPPORTED
335 const char *message );
428 const char *message );
884 int default_facility );
942 const char *app_name );
1189 const char *message,
1249 const char *message );
1313 const char *message,
1370 const char *message );
1446 const char *message,
1492 const char *message,
1555 const char *message,
1614 const char *message,
#define STUMPLESS_PUBLIC_FUNCTION
Marks functions that are provided for use by the library.
Definition config.h:31
Types and functions for creating and modifying entries.
#define STUMPLESS_MAX_APP_NAME_LENGTH
The maximum length of an app name, as specified by RFC 5424.
Definition entry.h:43
#define STUMPLESS_MAX_MSGID_LENGTH
The maximum length of a msgid, as specified by RFC 5424.
Definition entry.h:46
Generic functionality to be used with STUMPLESS_FOREACH macros to allow for more generic definition o...
The identification for targets within the library.
void * stumpless_id_t
Definition id.h:30
A log entry.
Definition entry.h:60
A target that log entries can be sent to.
Definition target.h:140
stumpless_filter_func_t filter
A filter function used to determine if a given entry should be processed by this target or ignored.
Definition target.h:190
char * name
The name of this target.
Definition target.h:157
stumpless_id_t id
A unique identifier of this target.
Definition target.h:142
size_t name_length
The number of characters in the name.
Definition target.h:159
char default_app_name[STUMPLESS_MAX_APP_NAME_LENGTH]
The app name used for messages without one provided.
Definition target.h:169
int mask
The log mask for the target.
Definition target.h:181
size_t default_app_name_length
The number of characters in the default app name.
Definition target.h:171
int default_prival
The prival used for messages without a severity or facility provided.
Definition target.h:163
int options
A bitwise or of all options set on the target.
Definition target.h:161
char default_msgid[STUMPLESS_MAX_MSGID_LENGTH]
The msgid used for messages without one provided.
Definition target.h:177
enum stumpless_target_type type
The type of this target.
Definition target.h:147
size_t default_msgid_length
The number of characters in the default msgid.
Definition target.h:179
STUMPLESS_PUBLIC_FUNCTION int vstumpless_add_log(struct stumpless_target *target, int priority, const char *message, va_list subs)
Adds a log message with a priority to a given target.
STUMPLESS_PUBLIC_FUNCTION int stumpless_trace_entry(struct stumpless_target *target, struct stumpless_entry *entry, const char *file, int line, const char *func)
Adds an entry into a given target.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_target * stumpless_get_current_target(void)
Gets the current target.
STUMPLESS_PUBLIC_FUNCTION FILE * stumpless_get_cons_stream(void)
STUMPLESS_PUBLIC_FUNCTION struct stumpless_target * stumpless_set_target_filter(struct stumpless_target *target, stumpless_filter_func_t filter)
Sets the filter used to determine whether entries should be logged by a given target.
STUMPLESS_PUBLIC_FUNCTION stumpless_filter_func_t stumpless_get_target_filter(const struct stumpless_target *target)
Returns the current filter used by the given target to determine if entries should be allowed through...
STUMPLESS_PUBLIC_FUNCTION int stumpless_get_default_facility(const struct stumpless_target *target)
Gets the default facility of a target.
STUMPLESS_PUBLIC_FUNCTION int stumpless_add_log_str(struct stumpless_target *target, int priority, const char *message)
Adds a log message with a priority to a given target.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_target * stumpless_unset_option(struct stumpless_target *target, int option)
Unsets an option on a target.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_target * stumpless_open_target(struct stumpless_target *target)
Opens a target that has already been created and configured.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_target * stumpless_set_target_mask(struct stumpless_target *target, int mask)
Sets the log mask of a target.
STUMPLESS_PUBLIC_FUNCTION void stumpless_set_cons_stream(FILE *stream)
Sets the console stream to write logs to.
STUMPLESS_PUBLIC_FUNCTION const char * stumpless_get_target_default_app_name(const struct stumpless_target *target)
Returns the default app name of the given target.
STUMPLESS_PUBLIC_FUNCTION int vstumpless_trace_log(struct stumpless_target *target, int priority, const char *file, int line, const char *func, const char *message, va_list subs)
Adds a log message with a priority to a given target, along with the file, line, and function informa...
STUMPLESS_PUBLIC_FUNCTION int stumpless_add_message_str(struct stumpless_target *target, const char *message)
Adds a string message to a given target.
STUMPLESS_PUBLIC_FUNCTION int stumpless_get_target_mask(const struct stumpless_target *target)
Gets the log mask of a target.
STUMPLESS_PUBLIC_FUNCTION const char * stumpless_get_target_default_msgid(const struct stumpless_target *target)
Returns the default msgid of the given target.
STUMPLESS_PUBLIC_FUNCTION int stumpless_trace_log_str(struct stumpless_target *target, int priority, const char *file, int line, const char *func, const char *message)
Adds a log message with a priority to a given target, along with the file, line, and function informa...
STUMPLESS_PUBLIC_FUNCTION int vstumpless_trace_message(struct stumpless_target *target, const char *file, int line, const char *func, const char *message, va_list subs)
Adds a message to a given target, along with the file, line, and function information specified in a ...
STUMPLESS_PUBLIC_FUNCTION struct stumpless_target * stumpless_get_default_target(void)
Gets the default target.
STUMPLESS_PUBLIC_FUNCTION void stumpless_close_target(struct stumpless_target *target)
Closes a target.
stumpless_target_type
Types of targets that may be created.
Definition target.h:101
@ STUMPLESS_GENERATE_ENUM
Definition target.h:102
STUMPLESS_PUBLIC_FUNCTION struct stumpless_target * stumpless_set_target_default_app_name(struct stumpless_target *target, const char *app_name)
Sets the default app name for a given target.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_target * stumpless_set_option(struct stumpless_target *target, int option)
Sets an option on a target.
#define STUMPLESS_FOREACH_TARGET_TYPE(ACTION)
A macro function that runs the provided action once for each target_type, providing the symbol and va...
Definition target.h:86
STUMPLESS_PUBLIC_FUNCTION int stumpless_get_option(const struct stumpless_target *target, int option)
Gets a given option of a target.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_target * stumpless_set_target_default_msgid(struct stumpless_target *target, const char *msgid)
Sets the default msgid for a given target.
STUMPLESS_PUBLIC_FUNCTION const char * stumpless_get_target_type_string(enum stumpless_target_type target_type)
Gets the string representation of the given target_type.
STUMPLESS_PUBLIC_FUNCTION int vstumpless_add_message(struct stumpless_target *target, const char *message, va_list subs)
Adds a message to a given target.
STUMPLESS_PUBLIC_FUNCTION const char * stumpless_get_target_name(const struct stumpless_target *target)
Returns the name of the given target.
STUMPLESS_PUBLIC_FUNCTION const struct stumpless_target * stumpless_target_is_open(const struct stumpless_target *target)
Checks to see if the given target is open.
bool(* stumpless_filter_func_t)(const struct stumpless_target *target, const struct stumpless_entry *entry)
A function that determines whether a given entry should be sent to a given target.
Definition target.h:133
STUMPLESS_PUBLIC_FUNCTION int stumpless_add_log(struct stumpless_target *target, int priority, const char *message,...)
Adds a log message with a priority to a given target.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_target * stumpless_set_default_facility(struct stumpless_target *target, int default_facility)
Sets the default facility of a target.
STUMPLESS_PUBLIC_FUNCTION void stumpless_set_current_target(struct stumpless_target *target)
Sets the target used when one is not provided.
STUMPLESS_PUBLIC_FUNCTION int stumpless_trace_message_str(struct stumpless_target *target, const char *file, int line, const char *func, const char *message)
Adds a message to a given target, along with the file, line, and function information specified in a ...
STUMPLESS_PUBLIC_FUNCTION int stumpless_add_message(struct stumpless_target *target, const char *message,...)
Adds a message to a given target.
STUMPLESS_PUBLIC_FUNCTION int stumpless_trace_message(struct stumpless_target *target, const char *file, int line, const char *func, const char *message,...)
Adds a message to a given target, along with the file, line, and function information specified in a ...
STUMPLESS_PUBLIC_FUNCTION int stumpless_add_entry(struct stumpless_target *target, const struct stumpless_entry *entry)
Adds an entry into a given target.
STUMPLESS_PUBLIC_FUNCTION int stumpless_trace_log(struct stumpless_target *target, int priority, const char *file, int line, const char *func, const char *message,...)
Adds a log message with a priority to a given target, along with the file, line, and function informa...