Demonstrates how to work with a network target with a TCP network endpoint.
Demonstrates how to work with a network target with a TCP network endpoint.
#include <stdlib.h>
int
main( int argc, char **argv ) {
const char *log_server = "example.com";
const char *port = "5514";
int log_result;
STUMPLESS_SEVERITY_INFO,
"example-app-name",
"example-msgid",
"This is an example message." );
if( !basic_entry ) {
return EXIT_FAILURE;
}
if( !result ) {
return EXIT_FAILURE;
}
if( !element_result ) {
return EXIT_FAILURE;
}
if( !tcp_target ) {
return EXIT_FAILURE;
}
if( !target_result ) {
return EXIT_FAILURE;
}
if( !target_result ) {
return EXIT_FAILURE;
}
STUMPLESS_FACILITY_LOCAL0 );
if( !target_result ) {
return EXIT_FAILURE;
}
if( !target_result ) {
stumpless_perror(
"couldn't open the target. are you sure that the server is listening on the right port?" );
return EXIT_SUCCESS;
}
if( log_result < 0 ) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
STUMPLESS_PUBLIC_FUNCTION struct stumpless_element * stumpless_add_param(struct stumpless_element *element, struct stumpless_param *param)
Adds a param to an element.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_element * stumpless_new_element(const char *name)
Creates a new element with the given name.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_entry * stumpless_add_element(struct stumpless_entry *entry, struct stumpless_element *element)
Adds an element to an entry.
STUMPLESS_PUBLIC_FUNCTION void stumpless_destroy_entry_and_contents(const struct stumpless_entry *entry)
Destroys an entry as well as all elements and params that it contains, freeing any allocated memory.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_entry * stumpless_new_entry(enum stumpless_facility facility, enum stumpless_severity severity, const char *app_name, const char *msgid, const char *message,...)
Creates a new entry with the given characteristics.
STUMPLESS_PUBLIC_FUNCTION void stumpless_perror(const char *prefix)
Prints information about the current error to the error stream.
STUMPLESS_PUBLIC_FUNCTION void stumpless_free_all(void)
Closes the default target if it has been opened, frees all memory allocated internally,...
STUMPLESS_PUBLIC_FUNCTION void stumpless_close_network_target(const struct stumpless_target *target)
Closes a network target.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_target * stumpless_set_transport_port(struct stumpless_target *target, const char *port)
Sets the transport port number of a network target.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_target * stumpless_set_destination(struct stumpless_target *target, const char *destination)
Sets the destination of a network target.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_target * stumpless_new_tcp4_target(const char *name)
Creates a network target for logging over IPv4 and TCP, but does not open it.
STUMPLESS_PUBLIC_FUNCTION struct stumpless_param * stumpless_new_param(const char *name, const char *value)
Creates a new param with the given name and value.
An element of structured data.
Definition element.h:93
A log entry.
Definition entry.h:60
A parameter within a structured data element.
Definition param.h:93
A target that log entries can be sent to.
Definition target.h:140
The main header file for the stumpless logging library.
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_default_facility(struct stumpless_target *target, int default_facility)
Sets the default facility of a target.
STUMPLESS_PUBLIC_FUNCTION int stumpless_add_entry(struct stumpless_target *target, const struct stumpless_entry *entry)
Adds an entry into a given target.