problem with accents in log messages
Hello, syslog-ng version: 2.0.2 System: RHEL4, locale: en_US.UTF-8 Without a template in the destionation, the accented characters appear well: Using this config: source s_net { tcp(); udp(); }; destination d_nettest { file("/var/log/nettest.log"); }; filter f_nettest { host(localhost); }; log {source(s_net); filter(f_nettest); destination(d_nettest); }; Then I do a 'nc localhost 514' and type 'abbé', I properly receive 'Apr 5 10:49:59 localhost/localhost abbé' in /var/log/nettest.log. However, using this config: source s_net { tcp(); udp(); }; destination d_nettest { file("/var/log/nettest.log" template ("$YEAR.$MONTH.$DAY $HOUR:$MIN:$SEC $TZOFFSET $HOST $MSG\n")); ); }; filter f_nettest { host(localhost); }; log {source(s_net); filter(f_nettest); destination(d_nettest); }; I receive this: 2007.04.05 10:48:51 +02:00 localhost abb\37777777751 Thus, 'é' is converted to '\37777777751' Is it a known bug or am I missing something? Thanks, Daniel ps: eljenek a veszpremi infosok
Hello, Got it, template_escape(no) solves the problem. Thanks, Daniel Nagy Daniel wrote:
Hello,
syslog-ng version: 2.0.2 System: RHEL4, locale: en_US.UTF-8
Without a template in the destionation, the accented characters appear well:
Using this config: source s_net { tcp(); udp(); }; destination d_nettest { file("/var/log/nettest.log"); }; filter f_nettest { host(localhost); }; log {source(s_net); filter(f_nettest); destination(d_nettest); };
Then I do a 'nc localhost 514' and type 'abbé', I properly receive 'Apr 5 10:49:59 localhost/localhost abbé' in /var/log/nettest.log.
However, using this config: source s_net { tcp(); udp(); }; destination d_nettest { file("/var/log/nettest.log" template ("$YEAR.$MONTH.$DAY $HOUR:$MIN:$SEC $TZOFFSET $HOST $MSG\n")); ); }; filter f_nettest { host(localhost); }; log {source(s_net); filter(f_nettest); destination(d_nettest); };
I receive this: 2007.04.05 10:48:51 +02:00 localhost abb\37777777751
Thus, 'é' is converted to '\37777777751'
Is it a known bug or am I missing something?
Thanks,
Daniel
ps: eljenek a veszpremi infosok _______________________________________________ syslog-ng maillist - syslog-ng@lists.balabit.hu https://lists.balabit.hu/mailman/listinfo/syslog-ng Frequently asked questions at http://www.campin.net/syslog-ng/faq.html
On Thu, 2007-04-05 at 11:47 +0200, Nagy Daniel wrote:
Hello,
Got it, template_escape(no) solves the problem.
This is a genuine bug nevertheless. The patch below should fix it (in fact the single gchar->guchar change is the fix, the rest is just cosmetics and a testcase update to cover this case): --- orig/src/macros.c +++ mod/src/macros.c @@ -111,7 +111,7 @@ macros[] = GHashTable *macro_hash; static void -result_append(GString *result, gchar *str, gint len, gboolean escape) +result_append(GString *result, guchar *str, gsize len, gboolean escape) { gint i; @@ -126,7 +126,7 @@ result_append(GString *result, gchar *st } else if (str[i] < ' ') { - g_string_sprintfa(result, "\\%03o", (unsigned int) str[i]); + g_string_sprintfa(result, "\\%03o", str[i]); } else g_string_append_c(result, str[i]); --- orig/tests/unit/test_template.c +++ mod/tests/unit/test_template.c @@ -2,6 +2,7 @@ #include "logmsg.h" #include "templates.h" #include "misc.h" +#include "macros.h" #include <time.h> #include <stdlib.h> @@ -16,7 +17,7 @@ testcase(LogMessage *msg, gchar *templat GString *res = g_string_sized_new(128); templ = log_template_new("dummy", template); - log_template_format(templ, msg, 0, TS_FMT_BSD, -1, 3, res); + log_template_format(templ, msg, MF_ESCAPE_RESULT, TS_FMT_BSD, -1, 3, res); if (strcmp(res->str, expected) != 0) { @@ -35,7 +36,7 @@ int main(int argc G_GNUC_UNUSED, char *argv[] G_GNUC_UNUSED) { LogMessage *msg; - char *msg_str = "<155>2006-02-11T10:34:56+01:00 bzorp syslog-ng[23323]: test message"; + char *msg_str = "<155>2006-02-11T10:34:56+01:00 bzorp syslog-ng[23323]: árvíztűrőtükörfúrógép"; putenv("TZ=CET"); tzset(); @@ -108,9 +109,9 @@ main(int argc G_GNUC_UNUSED, char *argv[ testcase(msg, "$FULLHOST", "bzorp"); testcase(msg, "$PROGRAM", "syslog-ng"); testcase(msg, "$PID", "23323"); - testcase(msg, "$MSG", "syslog-ng[23323]: test message"); - testcase(msg, "$MSGONLY", "test message"); - testcase(msg, "$MESSAGE", "syslog-ng[23323]: test message"); + testcase(msg, "$MSG", "syslog-ng[23323]: árvíztűrőtükörfúrógép"); + testcase(msg, "$MSGONLY", "árvíztűrőtükörfúrógép"); + testcase(msg, "$MESSAGE", "syslog-ng[23323]: árvíztűrőtükörfúrógép"); testcase(msg, "$SOURCEIP", "10.10.10.10"); testcase(msg, "$PROGRAM/var/log/messages/$HOST/$HOST_FROM/$MONTH$DAY$QQQQQvalami", "syslog-ng/var/log/messages/bzorp/kismacska/0211valami"); if (success) -- Bazsi
participants (2)
-
Balazs Scheidler
-
Nagy Daniel