Go to the documentation of this file.
27 #ifndef __STUMPLESS_TARGET_H
28 # define __STUMPLESS_TARGET_H
40 # define STUMPLESS_DEFAULT_FILE "stumpless-default.log"
43 # define STUMPLESS_DEFAULT_TARGET_NAME "stumpless-default"
50 # define STUMPLESS_BUFFER_TARGET_VALUE 0
53 # define STUMPLESS_FILE_TARGET_VALUE 1
56 # define STUMPLESS_FUNCTION_TARGET_VALUE 2
59 # define STUMPLESS_JOURNALD_TARGET_VALUE 3
62 # define STUMPLESS_NETWORK_TARGET_VALUE 4
65 # define STUMPLESS_SOCKET_TARGET_VALUE 5
68 # define STUMPLESS_STREAM_TARGET_VALUE 6
71 # define STUMPLESS_WINDOWS_EVENT_LOG_TARGET_VALUE 7
79 # define STUMPLESS_FOREACH_TARGET_TYPE( ACTION )\
81 ACTION( STUMPLESS_BUFFER_TARGET, STUMPLESS_BUFFER_TARGET_VALUE )\
83 ACTION( STUMPLESS_FILE_TARGET, STUMPLESS_FILE_TARGET_VALUE )\
85 ACTION( STUMPLESS_FUNCTION_TARGET, STUMPLESS_FUNCTION_TARGET_VALUE )\
87 ACTION( STUMPLESS_JOURNALD_TARGET, STUMPLESS_JOURNALD_TARGET_VALUE )\
89 ACTION( STUMPLESS_NETWORK_TARGET, STUMPLESS_NETWORK_TARGET_VALUE )\
91 ACTION( STUMPLESS_SOCKET_TARGET, STUMPLESS_SOCKET_TARGET_VALUE )\
93 ACTION( STUMPLESS_STREAM_TARGET, STUMPLESS_STREAM_TARGET_VALUE )\
95 ACTION( STUMPLESS_WINDOWS_EVENT_LOG_TARGET, STUMPLESS_WINDOWS_EVENT_LOG_TARGET_VALUE )
187 # ifdef STUMPLESS_THREAD_SAFETY_SUPPORTED
325 const char *message );
414 const char *message );
865 int default_facility );
923 const char *app_name );
1166 const char *message,
1224 const char *message );
1286 const char *message,
1341 const char *message );
1415 const char *message,
1459 const char *message,
1520 const char *message,
1577 const char *message,
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.
const char * stumpless_get_target_default_msgid(const struct stumpless_target *target)
Returns the default msgid of the given target.
int stumpless_get_option(const struct stumpless_target *target, int option)
Gets a given option of a target.
void stumpless_set_cons_stream(FILE *stream)
Sets the console stream to write logs to.
struct stumpless_target * stumpless_set_target_default_msgid(struct stumpless_target *target, const char *msgid)
Sets the default msgid for a given target.
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_target_type
Types of targets that may be created.
Definition: target.h:98
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:185
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.
int default_prival
The prival used for messages without a severity or facility provided.
Definition: target.h:159
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 ...
char * name
The name of this target.
Definition: target.h:153
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.
#define STUMPLESS_GENERATE_ENUM(NAME, VALUE)
Returns a definition of a symbol with the given name and value fit for use in an enum definition.
Definition: generator.h:33
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_id_t id
A unique identifier of this target.
Definition: target.h:138
int vstumpless_add_message(struct stumpless_target *target, const char *message, va_list subs)
Adds a message to a given target.
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...
const char * stumpless_get_target_default_app_name(const struct stumpless_target *target)
Returns the default app name of the given target.
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.
A target that log entries can be sent to.
Definition: target.h:136
int stumpless_add_message_str(struct stumpless_target *target, const char *message)
Adds a string message to a given target.
enum stumpless_target_type type
The type of this target.
Definition: target.h:143
int stumpless_add_log(struct stumpless_target *target, int priority, const char *message,...)
Adds a log message with a priority to a given target.
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...
struct stumpless_target * stumpless_get_current_target(void)
Gets the current target.
#define STUMPLESS_MAX_APP_NAME_LENGTH
The maximum length of an app name, as specified by RFC 5424.
Definition: entry.h:43
char default_msgid[32]
The msgid used for messages without one provided.
Definition: target.h:173
void stumpless_set_current_target(struct stumpless_target *target)
Sets the target used when one is not provided.
const char * stumpless_get_target_name(const struct stumpless_target *target)
Returns the name of the given target.
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:129
struct stumpless_target * stumpless_get_default_target(void)
Gets the default target.
size_t default_msgid_length
The number of characters in the default msgid.
Definition: target.h:175
int stumpless_add_entry(struct stumpless_target *target, const struct stumpless_entry *entry)
Adds an entry into a given target.
void stumpless_close_target(struct stumpless_target *target)
Closes a target.
size_t name_length
The number of characters in the name.
Definition: target.h:155
const struct stumpless_target * stumpless_target_is_open(const struct stumpless_target *target)
Checks to see if the given target is open.
FILE * stumpless_get_cons_stream(void)
struct stumpless_target * stumpless_set_default_facility(struct stumpless_target *target, int default_facility)
Sets the default facility of a target.
int stumpless_get_target_mask(const struct stumpless_target *target)
Gets the log mask of a target.
struct stumpless_target * stumpless_unset_option(struct stumpless_target *target, int option)
Unsets an option on a target.
struct stumpless_target * stumpless_set_target_mask(struct stumpless_target *target, int mask)
Sets the log mask of a target.
struct stumpless_target * stumpless_open_target(struct stumpless_target *target)
Opens a target that has already been created and configured.
void * stumpless_id_t
Definition: id.h:30
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 ...
#define STUMPLESS_PUBLIC_FUNCTION
Marks functions that are provided for use by the library.
Definition: config.h:31
struct stumpless_target * stumpless_set_option(struct stumpless_target *target, int option)
Sets an option on a target.
int mask
The log mask for the target.
Definition: target.h:177
const char * stumpless_get_target_type_string(enum stumpless_target_type target)
Gets the string representation of the given target_type.
int stumpless_add_message(struct stumpless_target *target, const char *message,...)
Adds a message to a given target.
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.
void * mutex
A pointer to a mutex which protects all target fields.
Definition: target.h:191
A log entry.
Definition: entry.h:63
int options
A bitwise or of all options set on the target.
Definition: target.h:157
#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:79
#define STUMPLESS_MAX_MSGID_LENGTH
The maximum length of a msgid, as specified by RFC 5424.
Definition: entry.h:46
int stumpless_get_default_facility(const struct stumpless_target *target)
Gets the default facility of a target.
size_t default_app_name_length
The number of characters in the default app name.
Definition: target.h:167
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...
char default_app_name[48]
The app name used for messages without one provided.
Definition: target.h:165