summaryrefslogtreecommitdiffstats
path: root/template.c
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2012-08-11 09:52:53 +0200
committerMiloslav Trmač <mitr@redhat.com>2012-08-28 10:26:42 +0200
commit02ea1d97657ed81797e02ef80c7f89195cf82a27 (patch)
treeec8743360626300e365e8c120e2bdfb7048ad695 /template.c
parentf2068e080718f28b98034233ea08b50f3d2ab220 (diff)
downloadrsyslog-ommongodb.zip
rsyslog-ommongodb.tar.gz
rsyslog-ommongodb.tar.xz
Add support for optional JSON fieldsHEADommongodb
These fields are only relevant in field templates (i.e. mongodb): a field for a non-existent CEE property is not created (instead of being set to an empty string). Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Diffstat (limited to 'template.c')
-rw-r--r--template.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/template.c b/template.c
index d9ca071..298f813 100644
--- a/template.c
+++ b/template.c
@@ -669,6 +669,8 @@ static void doOptions(unsigned char **pp, struct templateEntry *pTpe)
} else {
pTpe->data.field.options.bJSONf = 1;
}
+ } else if(!strcmp((char*)Buf, "optional-field")) {
+ pTpe->data.field.options.bOptionalField = 1;
} else {
dbgprintf("Invalid field option '%s' specified - ignored.\n", Buf);
}
@@ -1984,6 +1986,9 @@ void tplPrintList(rsconf_t *conf)
if(pTpe->data.field.options.bJSONf) {
dbgprintf("[format as JSON field] ");
}
+ if(pTpe->data.field.options.bOptionalField) {
+ dbgprintf("[optional field - skip in field template if not present] ");
+ }
if(pTpe->data.field.options.bDropLastLF) {
dbgprintf("[drop last LF in msg] ");
}