syslog-ng source
synthetic-message.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002-2013, 2015 Balabit
3  * Copyright (c) 1998-2013, 2015 Balázs Scheidler
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 as published
7  * by the Free Software Foundation, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * As an additional exemption you are allowed to compile & link against the
19  * OpenSSL libraries as published by the OpenSSL project. See the file
20  * COPYING for details.
21  *
22  */
23 #ifndef CORRELATION_SYNTHETIC_MESSAGE_H_INCLUDED
24 #define CORRELATION_SYNTHETIC_MESSAGE_H_INCLUDED
25 
26 #include "syslog-ng.h"
27 #include "correlation-context.h"
28 #include "template/templates.h"
29 
30 typedef enum
31 {
36 
37 typedef struct _SyntheticMessageValue
38 {
39  gchar *name;
41  LogTemplate *value_template;
43 
44 typedef struct _SyntheticMessage
45 {
47  GArray *tags;
48  GArray *values;
49  gchar *prefix;
51 
53 LogMessage *synthetic_message_generate_with_context(SyntheticMessage *self, CorrelationContext *context);
54 
55 
56 void synthetic_message_apply(SyntheticMessage *self, CorrelationContext *context, LogMessage *msg);
57 gboolean synthetic_message_add_value_template_string(SyntheticMessage *self, GlobalConfig *cfg, const gchar *name,
58  const gchar *value, GError **error);
60  const gchar *name,
61  const gchar *value, const gchar *type_hint, GError **error);
62 
64 void synthetic_message_set_inherit_properties_string(SyntheticMessage *self, const gchar *inherit_properties,
65  GError **error);
66 gboolean synthetic_message_set_inherit_mode_string(SyntheticMessage *self, const gchar *inherit_mode_name,
67  GError **error);
68 void synthetic_message_add_value_template(SyntheticMessage *self, const gchar *name, LogTemplate *value);
69 void synthetic_message_add_tag(SyntheticMessage *self, const gchar *text);
70 void synthetic_message_set_prefix(SyntheticMessage *self, const gchar *prefix);
75 
76 gint synthetic_message_lookup_inherit_mode(const gchar *inherit_mode);
77 
78 static inline SyntheticMessageValue *
79 synthetic_message_values_index(SyntheticMessage *self, gint index_)
80 {
81  return &g_array_index(self->values, SyntheticMessageValue, index_);
82 }
83 
84 static inline guint
85 synthetic_message_tags_index(SyntheticMessage *self, gint index_)
86 {
87  return g_array_index(self->tags, LogTagId, index_);
88 }
89 
90 #endif
const gchar * name
Definition: debugger.c:265
guint32 NVHandle
Definition: nvtable.h:35
#define self
Definition: rcptid.c:38
Definition: synthetic-message.h:38
NVHandle handle
Definition: synthetic-message.h:40
gchar * name
Definition: synthetic-message.h:39
LogTemplate * value_template
Definition: synthetic-message.h:41
Definition: synthetic-message.h:45
SyntheticMessageInheritMode inherit_mode
Definition: synthetic-message.h:46
gchar * prefix
Definition: synthetic-message.h:49
GArray * values
Definition: synthetic-message.h:48
GArray * tags
Definition: synthetic-message.h:47
void synthetic_message_init(SyntheticMessage *self)
Definition: synthetic-message.c:347
void synthetic_message_add_value_template(SyntheticMessage *self, const gchar *name, LogTemplate *value)
Definition: synthetic-message.c:170
void synthetic_message_set_inherit_properties_string(SyntheticMessage *self, const gchar *inherit_properties, GError **error)
Definition: synthetic-message.c:51
gboolean synthetic_message_add_value_template_string(SyntheticMessage *self, GlobalConfig *cfg, const gchar *name, const gchar *value, GError **error)
Definition: synthetic-message.c:107
void synthetic_message_free(SyntheticMessage *self)
Definition: synthetic-message.c:385
void synthetic_message_deinit(SyntheticMessage *self)
Definition: synthetic-message.c:353
gint synthetic_message_lookup_inherit_mode(const gchar *inherit_mode)
Definition: synthetic-message.c:392
void synthetic_message_set_prefix(SyntheticMessage *self, const gchar *prefix)
Definition: synthetic-message.c:185
SyntheticMessageInheritMode
Definition: synthetic-message.h:31
@ RAC_MSG_INHERIT_LAST_MESSAGE
Definition: synthetic-message.h:33
@ RAC_MSG_INHERIT_CONTEXT
Definition: synthetic-message.h:34
@ RAC_MSG_INHERIT_NONE
Definition: synthetic-message.h:32
LogMessage * synthetic_message_generate_without_context(SyntheticMessage *self, LogMessage *msg)
Definition: synthetic-message.c:324
void synthetic_message_apply(SyntheticMessage *self, CorrelationContext *context, LogMessage *msg)
Definition: synthetic-message.c:210
void synthetic_message_add_tag(SyntheticMessage *self, const gchar *text)
Definition: synthetic-message.c:78
void synthetic_message_set_inherit_mode(SyntheticMessage *self, SyntheticMessageInheritMode inherit_mode)
Definition: synthetic-message.c:31
SyntheticMessage * synthetic_message_new(void)
Definition: synthetic-message.c:375
gboolean synthetic_message_add_value_template_string_and_type(SyntheticMessage *self, GlobalConfig *cfg, const gchar *name, const gchar *value, const gchar *type_hint, GError **error)
Definition: synthetic-message.c:89
gboolean synthetic_message_set_inherit_mode_string(SyntheticMessage *self, const gchar *inherit_mode_name, GError **error)
Definition: synthetic-message.c:37
LogMessage * synthetic_message_generate_with_context(SyntheticMessage *self, CorrelationContext *context)
Definition: synthetic-message.c:298
guint16 LogTagId
Definition: tags.h:31
GlobalConfig * cfg
Definition: test_batched_ack_tracker.c:34
GString * value
Definition: test_decode.c:28
LogMessage * msg
Definition: test_rename.c:35