Mstdlib-1.24.0
TCP Syslog Module

Functions

M_log_error_t M_log_module_add_tcp_syslog (M_log_t *log, const char *product, M_syslog_facility_t facility, const char *host, M_uint16 port, M_dns_t *dns, size_t max_queue_bytes, M_log_module_t **out_mod)
 
M_log_error_t M_log_module_tcp_syslog_set_connect_timeout_ms (M_log_t *log, M_log_module_t *module, M_uint64 timeout_ms)
 
M_log_error_t M_log_module_tcp_syslog_set_keepalives (M_log_t *log, M_log_module_t *module, M_uint64 idle_time_s, M_uint64 retry_time_s, M_uint64 retry_count)
 
M_log_error_t M_log_module_tcp_syslog_set_tag_priority (M_log_t *log, M_log_module_t *module, M_uint64 tags, M_syslog_priority_t priority)
 

Detailed Description

Functions to enable logging to a remote syslog server over TCP.

This module formats messages according to the legacy BSD syslog format from RFC 3164, and adds octet-counting framing as described in RFC 6587 for transmission over TCP. This legacy format was chosen to ensure compatibility across a wide range of syslog servers.

Messages are written asynchronously, as part of an existing event loop owned by the caller.

Note: syslog messages are limited to 1024 chars / line. Lines longer than this will be truncated.

Function Documentation

◆ M_log_module_add_tcp_syslog()

M_log_error_t M_log_module_add_tcp_syslog ( M_log_t log,
const char *  product,
M_syslog_facility_t  facility,
const char *  host,
M_uint16  port,
M_dns_t dns,
size_t  max_queue_bytes,
M_log_module_t **  out_mod 
)

Add a module to output to a remote syslog server over TCP.

This module formats messages according to the legacy BSD syslog format from RFC 3164, and adds octet-counting framing as described in RFC 6587 for transmission over TCP. This legacy format was chosen to ensure compatibility across a wide range of syslog servers.

Note: syslog messages are limited to 1024 chars / line. Lines longer than this will be truncated.

Parameters
[in]loglogger object
[in]productshort tag string for syslog, usually the name of the program sending log info
[in]facilityfacility type to associate with all log messages, gets passed directly to syslog
[in]hosthostname of destination syslog server
[in]portport of destination syslog server (usually 514)
[in]dnsexternal DNS resolver cache to use (not owned by logger)
[in]max_queue_bytesmax size of queue used to buffer asynchronous writes to syslog
[out]out_modhandle for created module, or NULL if there was an error
Returns
error code

◆ M_log_module_tcp_syslog_set_connect_timeout_ms()

M_log_error_t M_log_module_tcp_syslog_set_connect_timeout_ms ( M_log_t log,
M_log_module_t module,
M_uint64  timeout_ms 
)

Set TCP connection timeout.

Note that, in addition to normal connection parameters, the TCP module will automatically try to reconnect on disconnect or error after a short delay, no matter what you set here.

Parameters
[in]loglogger object
[in]modulehandle of module to operate on
[in]timeout_msconnection timeout, in milliseconds
Returns
error code

◆ M_log_module_tcp_syslog_set_keepalives()

M_log_error_t M_log_module_tcp_syslog_set_keepalives ( M_log_t log,
M_log_module_t module,
M_uint64  idle_time_s,
M_uint64  retry_time_s,
M_uint64  retry_count 
)

Set TCP keep alive parameters for the connection.

If this function isn't called, the following default values are used:

  • idle_time_s = 4 seconds
  • retry_time_s = 15 seconds
  • retry_count = 3
Parameters
[in]loglogger object
[in]modulehandle of module to operate on
[in]idle_time_stcp idle timeout, in seconds
[in]retry_time_stcp retry time, in seconds
[in]retry_counttcp allowed number of retries
Returns
error code

◆ M_log_module_tcp_syslog_set_tag_priority()

M_log_error_t M_log_module_tcp_syslog_set_tag_priority ( M_log_t log,
M_log_module_t module,
M_uint64  tags,
M_syslog_priority_t  priority 
)

Associate the given user-defined tag(s) with a syslog priority tag.

If you don't associate a tag with a syslog priority, the default priority of M_SYSLOG_INFO will be used for that tag.

See also
M_LOG_ALL_TAGS
M_log_all_tags_lt
M_log_all_tags_lte
M_log_all_tags_gt
M_log_all_tags_gte
Parameters
[in]loglogger object
[in]modulehandle of module to operate on
[in]tagsuser-defined power-of-two tag (or multiple power-of-two tags, OR'd together)
[in]prioritysingle priority value to associate with the given tags
Returns
error code