1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
/*
* Copyright (c) 2002-2014 Balabit
* Copyright (c) 1998-2014 Balázs Scheidler
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* As an additional exemption you are allowed to compile & link against the
* OpenSSL libraries as published by the OpenSSL project. See the file
* COPYING for details.
*
*/
#ifndef TEMPLATE_MACROS_H_INCLUDED
#define TEMPLATE_MACROS_H_INCLUDED
#include "syslog-ng.h"
#include "common-template-typedefs.h"
#include "eval.h"
/* macro IDs */
enum
{
M_NONE,
M_FACILITY,
M_FACILITY_NUM,
M_SEVERITY,
M_SEVERITY_NUM,
M_TAG,
M_TAGS,
M_BSDTAG,
M_PRI,
M_HOST,
M_SDATA,
M_MSGHDR,
M_MESSAGE,
M_SOURCE_IP,
M_DEST_IP,
M_DEST_PORT,
M_IP_PROTOCOL,
M_PROTOCOL,
M_RAWMSG_SIZE,
M_SEQNUM,
M_CONTEXT_ID,
M_LOGHOST,
M_SYSUPTIME,
M_RCPTID,
M_RUNID,
M_HOSTID,
M_UNIQID,
M__ASTERISK,
/* only touch this section if you want to add three macros, one w/o
* prefix, and a R_ and S_ prefixed macro that relates one of the
* timestamps of the log message. */
M_DATE,
M_FULLDATE,
M_ISODATE,
M_STAMP,
M_YEAR,
M_YEAR_DAY,
M_MONTH,
M_MONTH_WEEK,
M_MONTH_ABBREV,
M_MONTH_NAME,
M_DAY,
M_HOUR,
M_HOUR12,
M_MIN,
M_SEC,
M_USEC,
M_MSEC,
M_AMPM,
M_WEEK_DAY,
M_WEEK_DAY_ABBREV,
M_WEEK_DAY_NAME,
M_WEEK,
M_ISOWEEK,
M_TZOFFSET,
M_TZ,
M_UNIXTIME,
M_TIME_FIRST = M_DATE,
M_TIME_LAST = M_UNIXTIME,
M_TIME_MACROS_MAX = M_UNIXTIME - M_DATE + 1,
M_RECVD_OFS = M_TIME_MACROS_MAX,
M_STAMP_OFS = 2 * M_TIME_MACROS_MAX,
M_CSTAMP_OFS = 3 * M_TIME_MACROS_MAX,
M_PROCESSED_OFS = 4 * M_TIME_MACROS_MAX,
};
/* macros (not NV pairs!) that syslog-ng knows about. This was the
* earliest mechanism for inserting message-specific information into
* texts. It is now superseded by name-value pairs where the value is
* text, but remains to be used for time and other metadata.
*/
typedef struct _LogMacroDef
{
const char *name;
int id;
} LogMacroDef;
extern LogMacroDef macros[];
/* low level macro functions */
guint log_macro_lookup(const gchar *macro, gint len);
gboolean log_macro_expand(gint id, LogTemplateEvalOptions *options,
const LogMessage *msg,
GString *result, LogMessageValueType *type);
gboolean log_macro_expand_simple(gint id, const LogMessage *msg,
GString *result, LogMessageValueType *type);
void log_macros_global_init(void);
void log_macros_global_deinit(void);
#endif
|