Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions plugins/out_syslog/syslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,21 @@ static char rfc5424_sp_name[256] = {
static flb_sds_t syslog_rfc5424(flb_sds_t *s, struct flb_time *tms,
struct syslog_msg *msg)
{
int len;
struct tm tm;
flb_sds_t tmp;
uint8_t prival;

if (msg->message && msg->message[0] == '<') {
len = flb_sds_len(msg->message);
tmp = flb_sds_cat(*s, msg->message, len);
if (!tmp) {
return NULL;
}
*s = tmp;
return *s;
}

prival = (msg->facility << 3) + msg->severity;

if (gmtime_r(&(tms->tm.tv_sec), &tm) == NULL) {
Expand All @@ -163,7 +174,7 @@ static flb_sds_t syslog_rfc5424(flb_sds_t *s, struct flb_time *tms,
*s = tmp;

if (msg->hostname) {
int len = flb_sds_len(msg->hostname);
len = flb_sds_len(msg->hostname);
tmp = flb_sds_cat(*s, msg->hostname, len > 255 ? 255 : len);
if (!tmp) {
return NULL;
Expand All @@ -185,7 +196,7 @@ static flb_sds_t syslog_rfc5424(flb_sds_t *s, struct flb_time *tms,
*s = tmp;

if (msg->appname) {
int len = flb_sds_len(msg->appname);
len = flb_sds_len(msg->appname);
tmp = flb_sds_cat(*s, msg->appname, len > 48 ? 48 : len);
if (!tmp) {
return NULL;
Expand All @@ -207,7 +218,7 @@ static flb_sds_t syslog_rfc5424(flb_sds_t *s, struct flb_time *tms,
*s = tmp;

if (msg->procid) {
int len = flb_sds_len(msg->procid);
len = flb_sds_len(msg->procid);
tmp = flb_sds_cat(*s, msg->procid, len > 128 ? 128 : len);
if (!tmp) {
return NULL;
Expand All @@ -229,7 +240,7 @@ static flb_sds_t syslog_rfc5424(flb_sds_t *s, struct flb_time *tms,
*s = tmp;

if (msg->msgid) {
int len = flb_sds_len(msg->msgid);
len = flb_sds_len(msg->msgid);
tmp = flb_sds_cat(*s, msg->msgid, len > 32 ? 32 : len);
if (!tmp) {
return NULL;
Expand Down Expand Up @@ -266,7 +277,7 @@ static flb_sds_t syslog_rfc5424(flb_sds_t *s, struct flb_time *tms,
}

if (msg->message) {
int len = flb_sds_len(msg->message);
len = flb_sds_len(msg->message);
tmp = flb_sds_cat(*s, " \xef\xbb\xbf", 4);
if (!tmp) {
return NULL;
Expand All @@ -285,10 +296,21 @@ static flb_sds_t syslog_rfc5424(flb_sds_t *s, struct flb_time *tms,
static flb_sds_t syslog_rfc3164 (flb_sds_t *s, struct flb_time *tms,
struct syslog_msg *msg)
{
int len;
struct tm tm;
flb_sds_t tmp;
uint8_t prival;

if (msg->message && msg->message[0] == '<') {
len = flb_sds_len(msg->message);
tmp = flb_sds_cat(*s, msg->message, len);
if (!tmp) {
return NULL;
}
*s = tmp;
return *s;
}

prival = (msg->facility << 3) + msg->severity;

if (gmtime_r(&(tms->tm.tv_sec), &tm) == NULL) {
Expand Down Expand Up @@ -777,6 +799,7 @@ static void cb_syslog_flush(struct flb_event_chunk *event_chunk,

if (ctx->parsed_mode != FLB_SYSLOG_UDP) {
u_conn = flb_upstream_conn_get(ctx->u);

if (!u_conn) {
flb_plg_error(ctx->ins, "no upstream connections available");
FLB_OUTPUT_RETURN(FLB_RETRY);
Expand Down