summaryrefslogtreecommitdiffstats
path: root/runtime/msg.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 /runtime/msg.c
parentf2068e080718f28b98034233ea08b50f3d2ab220 (diff)
downloadrsyslog-02ea1d97657ed81797e02ef80c7f89195cf82a27.tar.gz
rsyslog-02ea1d97657ed81797e02ef80c7f89195cf82a27.tar.xz
rsyslog-02ea1d97657ed81797e02ef80c7f89195cf82a27.zip
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 'runtime/msg.c')
-rw-r--r--runtime/msg.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/runtime/msg.c b/runtime/msg.c
index 0d01f5e1..0ee78ae0 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -3500,6 +3500,14 @@ rsRetVal MsgAppendFields(msg_t *pMsg, struct templateEntry *pTpe,
}
}
} else {
+ /* FIXME: this performs a duplicate lookup, which wastes
+ time. */
+ if(pTpe->data.field.options.bOptionalField
+ && (pMsg->event == NULL
+ || ee_getEventField(pMsg->event,
+ pTpe->data.field.propName) == NULL))
+ FINALIZE; /* Nothing to do */
+
CHKiRet(FBSensureSpace(state));
dst = state->fields + state->nextField;