1 /* 2 * Copyright (c) 2020 Balabit 3 * Copyright (c) 2020 Balazs Scheidler <bazsi77@gmail.com> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 * 19 * As an additional exemption you are allowed to compile & link against the 20 * OpenSSL libraries as published by the OpenSSL project. See the file 21 * COPYING for details. 22 * 23 */ 24 25 #ifndef TEMPLATE_EVAL_H_INCLUDED 26 #define TEMPLATE_EVAL_H_INCLUDED 1 27 28 #include "syslog-ng.h" 29 #include "common-template-typedefs.h" 30 #include "timeutils/zoneinfo.h" 31 32 #define LTZ_LOCAL 0 33 #define LTZ_SEND 1 34 #define LTZ_MAX 2 35 36 /* template expansion options that can be influenced by the user and 37 * is static throughout the runtime for a given configuration. There 38 * are call-site specific options too, those are specified as 39 * arguments to log_template_format() */ 40 struct _LogTemplateOptions 41 { 42 gboolean initialized; 43 /* timestamp format as specified by ts_format() */ 44 gint ts_format; 45 /* number of digits in the fraction of a second part, specified using frac_digits() */ 46 gint frac_digits; 47 gboolean use_fqdn; 48 49 /* timezone for LTZ_LOCAL/LTZ_SEND settings */ 50 gchar *time_zone[LTZ_MAX]; 51 TimeZoneInfo *time_zone_info[LTZ_MAX]; 52 53 /* Template error handling settings */ 54 gint on_error; 55 }; 56 57 typedef struct _LogTemplateEvalOptions 58 { 59 /* options for recursive template evaluation, inherited from the parent */ 60 const LogTemplateOptions *opts; 61 gint tz; 62 gint seq_num; 63 const gchar *context_id; 64 } LogTemplateEvalOptions; 65 66 #define DEFAULT_TEMPLATE_EVAL_OPTIONS ((LogTemplateEvalOptions){NULL, LTZ_LOCAL, 0, NULL}) 67 68 void log_template_format(LogTemplate *self, LogMessage *lm, LogTemplateEvalOptions *options, GString *result); 69 void log_template_append_format(LogTemplate *self, LogMessage *lm, LogTemplateEvalOptions *options, GString *result); 70 void log_template_append_format_with_context(LogTemplate *self, LogMessage **messages, gint num_messages, 71 LogTemplateEvalOptions *options, GString *result); 72 void log_template_format_with_context(LogTemplate *self, LogMessage **messages, gint num_messages, 73 LogTemplateEvalOptions *options, GString *result); 74 75 #endif 76