Skip to content

Commit

Permalink
template: rename LEVEL to SEVERITY while keeping compatible naming
Browse files Browse the repository at this point in the history
Unfortunately, 20 years ago, syslog-ng choose the term "LEVEL" to refer to
the severity of a message, as that was the language used by syslog(3) manual
page.

Quoting the manpage:

       The priority argument is formed by ORing together a facility
       value and a level value (described below).  If no facility
       value is ORed into priority, then the default value set by
       openlog() is used, or, if there was no preceding openlog()
       call, a default of LOG_USER is employed.

However RFC3164 adopted the term "severity", quoting RFC3164:

       The number contained within these angle brackets is known as
       the Priority value and represents both the Facility and
       Severity as described below.

syslog-ng predates the choice in RFC3164, however I think it is highly time
to adopt the language of the RFC, especially as it is better than the
original.

See discussions in github PR syslog-ng#3115 for further details.

Signed-off-by: Balazs Scheidler <[email protected]>
  • Loading branch information
bazsi authored and Gabor Nagy committed Feb 24, 2020
1 parent 1cd4423 commit 6a6d3dd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
15 changes: 10 additions & 5 deletions lib/template/macros.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@ LogMacroDef macros[] =
{
{ "FACILITY", M_FACILITY },
{ "FACILITY_NUM", M_FACILITY_NUM },
{ "PRIORITY", M_LEVEL },
{ "LEVEL", M_LEVEL },
{ "LEVEL_NUM", M_LEVEL_NUM },
{ "SEVERITY", M_SEVERITY },
{ "SEVERITY_NUM", M_SEVERITY_NUM },

/* these are obsolete aliases of $SEVERITY that we support for compatibility only */
{ "PRIORITY", M_SEVERITY }, /* deprecated */
{ "LEVEL", M_SEVERITY }, /* deprecated */
{ "LEVEL_NUM", M_SEVERITY_NUM }, /* deprecated */

{ "TAG", M_TAG },
{ "TAGS", M_TAGS },
{ "BSDTAG", M_BSDTAG },
Expand Down Expand Up @@ -425,7 +430,7 @@ log_macro_expand(GString *result, gint id, gboolean escape, const LogTemplateOpt
format_uint32_padded(result, 0, 0, 10, (msg->pri & LOG_FACMASK) >> 3);
break;
}
case M_LEVEL:
case M_SEVERITY:
{
/* level */
const char *n;
Expand All @@ -442,7 +447,7 @@ log_macro_expand(GString *result, gint id, gboolean escape, const LogTemplateOpt

break;
}
case M_LEVEL_NUM:
case M_SEVERITY_NUM:
{
format_uint32_padded(result, 0, 0, 10, msg->pri & LOG_PRIMASK);
break;
Expand Down
4 changes: 2 additions & 2 deletions lib/template/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ enum

M_FACILITY,
M_FACILITY_NUM,
M_LEVEL,
M_LEVEL_NUM,
M_SEVERITY,
M_SEVERITY_NUM,
M_TAG,
M_TAGS,
M_BSDTAG,
Expand Down
5 changes: 5 additions & 0 deletions lib/template/tests/test_template.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,14 @@ Test(template, test_macros)

assert_template_format("$FACILITY", "local3");
assert_template_format("$FACILITY_NUM", "19");

assert_template_format("$SEVERITY", "err");
assert_template_format("$SEVERITY_NUM", "3");

assert_template_format("$PRIORITY", "err");
assert_template_format("$LEVEL", "err");
assert_template_format("$LEVEL_NUM", "3");

assert_template_format("$TAG", "9b");
assert_template_format("$TAGS", "alma,korte,citrom,\"tag,containing,comma\"");
assert_template_format("$PRI", "155");
Expand Down
6 changes: 3 additions & 3 deletions lib/value-pairs/tests/test_value_pairs.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ ParameterizedTestParameters(value_pairs, test)

{"all-nv-pairs", NULL, "[email protected],[email protected],.SDATA.meta.sequenceId,.SDATA.meta.sysUpTime,.SDATA.origin.ip,HOST,MESSAGE,MSGID,PID,PROGRAM", NULL },

{"everything", NULL, "[email protected],[email protected],.SDATA.meta.sequenceId,.SDATA.meta.sysUpTime,.SDATA.origin.ip,AMPM,BSDTAG,C_AMPM,C_DATE,C_DAY,C_FULLDATE,C_HOUR,C_HOUR12,C_ISODATE,C_ISOWEEK,C_MIN,C_MONTH,C_MONTH_ABBREV,C_MONTH_NAME,C_MONTH_WEEK,C_MSEC,C_SEC,C_STAMP,C_TZ,C_TZOFFSET,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_DAY,TAG,TAGS,TZ,TZOFFSET,UNIXTIME,USEC,WEEK,WEEKDAY,WEEK_DAY,WEEK_DAY_ABBREV,WEEK_DAY_NAME,YEAR,YEAR_DAY", NULL },
{"everything", NULL, "[email protected],[email protected],.SDATA.meta.sequenceId,.SDATA.meta.sysUpTime,.SDATA.origin.ip,AMPM,BSDTAG,C_AMPM,C_DATE,C_DAY,C_FULLDATE,C_HOUR,C_HOUR12,C_ISODATE,C_ISOWEEK,C_MIN,C_MONTH,C_MONTH_ABBREV,C_MONTH_NAME,C_MONTH_WEEK,C_MSEC,C_SEC,C_STAMP,C_TZ,C_TZOFFSET,C_UNIXTIME,C_USEC,C_WEEK,C_WEEKDAY,C_WEEK_DAY,C_WEEK_DAY_ABBREV,C_WEEK_DAY_NAME,C_YEAR,C_YEAR_DAY,DATE,DAY,FACILITY,FACILITY_NUM,FULLDATE,HOST,HOSTID,HOUR,HOUR12,ISODATE,ISOWEEK,LEVEL,LEVEL_NUM,LOGHOST,MESSAGE,MIN,MONTH,MONTH_ABBREV,MONTH_NAME,MONTH_WEEK,MSEC,MSG,MSGHDR,MSGID,PID,PRI,PRIORITY,PROGRAM,P_AMPM,P_DATE,P_DAY,P_FULLDATE,P_HOUR,P_HOUR12,P_ISODATE,P_ISOWEEK,P_MIN,P_MONTH,P_MONTH_ABBREV,P_MONTH_NAME,P_MONTH_WEEK,P_MSEC,P_SEC,P_STAMP,P_TZ,P_TZOFFSET,P_UNIXTIME,P_USEC,P_WEEK,P_WEEKDAY,P_WEEK_DAY,P_WEEK_DAY_ABBREV,P_WEEK_DAY_NAME,P_YEAR,P_YEAR_DAY,R_AMPM,R_DATE,R_DAY,R_FULLDATE,R_HOUR,R_HOUR12,R_ISODATE,R_ISOWEEK,R_MIN,R_MONTH,R_MONTH_ABBREV,R_MONTH_NAME,R_MONTH_WEEK,R_MSEC,R_SEC,R_STAMP,R_TZ,R_TZOFFSET,R_UNIXTIME,R_USEC,R_WEEK,R_WEEKDAY,R_WEEK_DAY,R_WEEK_DAY_ABBREV,R_WEEK_DAY_NAME,R_YEAR,R_YEAR_DAY,SDATA,SEC,SEQNUM,SEVERITY,SEVERITY_NUM,SOURCEIP,STAMP,SYSUPTIME,S_AMPM,S_DATE,S_DAY,S_FULLDATE,S_HOUR,S_HOUR12,S_ISODATE,S_ISOWEEK,S_MIN,S_MONTH,S_MONTH_ABBREV,S_MONTH_NAME,S_MONTH_WEEK,S_MSEC,S_SEC,S_STAMP,S_TZ,S_TZOFFSET,S_UNIXTIME,S_USEC,S_WEEK,S_WEEKDAY,S_WEEK_DAY,S_WEEK_DAY_ABBREV,S_WEEK_DAY_NAME,S_YEAR,S_YEAR_DAY,TAG,TAGS,TZ,TZOFFSET,UNIXTIME,USEC,WEEK,WEEKDAY,WEEK_DAY,WEEK_DAY_ABBREV,WEEK_DAY_NAME,YEAR,YEAR_DAY", NULL },

{"nv-pairs", ".SDATA.*", "HOST,MESSAGE,MSGID,PID,PROGRAM", NULL },

Expand All @@ -221,7 +221,7 @@ ParameterizedTestParameters(value_pairs, test)
};

return cr_make_param_array(struct value_pairs_params, params, sizeof (params) / sizeof(params[0]));
};
}

ParameterizedTest(struct value_pairs_params *param, value_pairs, test)
{
Expand Down Expand Up @@ -255,7 +255,7 @@ Test(value_pairs, test_transformers)
"R_HOUR,R_HOUR12,R_ISODATE,R_ISOWEEK,R_MIN,R_MONTH,R_MONTH_ABBREV,R_MONTH_NAME,"
"R_MONTH_WEEK,R_MSEC,R_SEC,R_STAMP,R_TZ,R_TZOFFSET,R_UNIXTIME,R_USEC,"
"R_WEEK,R_WEEKDAY,R_WEEK_DAY,R_WEEK_DAY_ABBREV,R_WEEK_DAY_NAME,R_YEAR,"
"R_YEAR_DAY,SDATA,SEC,SEQNUM,SOURCEIP,STAMP,SYSUPTIME,S_AMPM,S_DATE,"
"R_YEAR_DAY,SDATA,SEC,SEQNUM,SEVERITY,SEVERITY_NUM,SOURCEIP,STAMP,SYSUPTIME,S_AMPM,S_DATE,"
"S_DAY,S_FULLDATE,S_HOUR,S_HOUR12,S_ISODATE,S_ISOWEEK,S_MIN,S_MONTH,S_MONTH_ABBREV,"
"S_MONTH_NAME,S_MONTH_WEEK,S_MSEC,S_SEC,S_STAMP,S_TZ,S_TZOFFSET,S_UNIXTIME,"
"S_USEC,S_WEEK,S_WEEKDAY,S_WEEK_DAY,S_WEEK_DAY_ABBREV,S_WEEK_DAY_NAME,"
Expand Down

0 comments on commit 6a6d3dd

Please sign in to comment.