and there's the $LOGHOST macro which expands to the local hostname
bazsi@bzorp:~/zwa/work/syslog-ng-ose-3.4/syslog-ng-ose/lib$ git show 50d3289f
commit 50d3289f418f407f592d2b025e989a46840a3f76
Author: Balazs Scheidler <
bazsi@balabit.hu>
Date: Thu May 5 21:03:47 2011 +0200
templates: added $LOGHOST macro
This patch adds a new macro "$LOGHOST" which expands to the name of
the local hostname, as returned by the hostname command.
Signed-off-by: Andreas Piesk <
a.piesk@gmx.net>
Signed-off-by: Balazs Scheidler <
bazsi@balabit.hu>
diff --git a/lib/templates.c b/lib/templates.c
index 897365c..a3b85cf 100644
--- a/lib/templates.c
+++ b/lib/templates.c
@@ -59,6 +59,8 @@ enum
M_SEQNUM,
M_CONTEXT_ID,
+ M_LOGHOST,
+
M_DATE,
M_FULLDATE,
M_ISODATE,
@@ -181,6 +183,9 @@ LogMacroDef macros[] =
{ "MSG", M_MESSAGE },
{ "MESSAGE", M_MESSAGE },
{ "HOST", M_HOST },
+
+ /* message independent macros */
+ { "LOGHOST", M_LOGHOST },
{ NULL, 0 }
};
@@ -414,6 +419,14 @@ log_macro_expand(GString *result, gint id, gboolean escape, LogTemplateOptions *
}
break;
}
+ case M_LOGHOST:
+ {
+ gsize hname_len;
+ const gchar *hname = get_local_hostname(&hname_len);
+
+ result_append(result, hname, hname_len, escape);
+ break;
+ }
default:
{
/* year, month, day */