[syslog-ng] Output to file in /proc

Valentijn Sessink valentyn at blub.net
Wed Mar 2 12:28:31 CET 2011


Hi Balázs,

 > LogWriter: added support for a new flag 'ignore-errors'

Unfortunately, I can't get syslog-ng to re-write a broken message, even 
with fsync(yes). However, with your patch, it feels safer, because *if* 
a blocking message would be there, it would be ignored from now on.

On 02-03-11 10:42, Balazs Scheidler wrote:
> It is on 3.3 currently, but should probably be quite easy to backport it to 3.2

Yes, that was easy. For those interested:

diff --git a/lib/logwriter.c b/lib/logwriter.c
index b14cb57..968d22b 100644
--- a/lib/logwriter.c
+++ b/lib/logwriter.c
@@ -731,10 +731,18 @@ log_writer_flush(LogWriter *self, gboolean flush_all)
            status = log_proto_post(proto, (guchar *) line->str, 
line->len, &cons
            if (status == LPS_ERROR)
              {
-              msg_set_context(NULL);
-              g_string_free(line, TRUE);
-              return FALSE;
-            }
+             if ((self->options->options & LWO_IGNORE_ERRORS) == 0)
+               {
+                 msg_set_context(NULL);
+                 g_string_free(line, TRUE);
+                 return FALSE;
+               }
+             else
+               {
+                 consumed = TRUE;
+                 g_free(line->str);
+               }
+             }
            if (consumed)
              {
                line->str = g_malloc0(1);
@@ -991,6 +999,8 @@ log_writer_options_lookup_flag(const gchar *flag)
      return LWO_SYSLOG_PROTOCOL;
    if (strcmp(flag, "no-multi-line") == 0 || strcmp(flag, 
"no_multi_line") == 0)
      return LWO_NO_MULTI_LINE;
+  if (strcmp(flag, "ignore-errors") == 0 || strcmp(flag, 
"ignore_errors") == 0)
+    return LWO_IGNORE_ERRORS;
    msg_error("Unknown dest writer flag", evt_tag_str("flag", flag), NULL);
    return 0;
  }
diff --git a/lib/logwriter.h b/lib/logwriter.h
index 46244f4..7a316a1 100644
--- a/lib/logwriter.h
+++ b/lib/logwriter.h
@@ -45,6 +45,7 @@
  #define LWO_NO_STATS        0x0004
  /* several writers use the same counter */
  #define LWO_SHARE_STATS     0x0008
+#define LWO_IGNORE_ERRORS   0x0020

  typedef struct _LogWriterOptions
  {



More information about the syslog-ng mailing list