diff options
author | Miloslav Trmač <mitr@redhat.com> | 2012-08-29 16:07:23 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2012-08-29 16:07:23 +0200 |
commit | a73058031f13f46f79a2697519271a854f04c7d5 (patch) | |
tree | 00ab293b30f6cc3bd14e01041f4b0ea2f395bde0 | |
parent | d18a93e943b4552890a0e603b9fc7db5a6fd7761 (diff) | |
download | rsyslog-a73058031f13f46f79a2697519271a854f04c7d5.tar.gz rsyslog-a73058031f13f46f79a2697519271a854f04c7d5.tar.bz2 rsyslog-a73058031f13f46f79a2697519271a854f04c7d5.zip |
Add support for optional fields
-rw-r--r-- | doc/property_replacer.html | 4 | ||||
-rw-r--r-- | template.c | 5 | ||||
-rw-r--r-- | template.h | 1 |
3 files changed, 10 insertions, 0 deletions
diff --git a/doc/property_replacer.html b/doc/property_replacer.html index 943c4f73..217b6dc0 100644 --- a/doc/property_replacer.html +++ b/doc/property_replacer.html @@ -714,6 +714,10 @@ Useful for secure pathname generation (with dynafiles). Useful for secure pathname generation (with dynafiles). </td> </tr> +<tr> +<td><b>optional-field</b></td> +<td>In templates that are used for building field lists (in particular, ommongodb), completely remove this field if the corresponding property is not present. Currently implemented only for the <b>$!<name></b> properties.</td> +</tr> </tbody> </table> <p>To use multiple options, simply place them one after each other with a comma delmimiting @@ -663,6 +663,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); } @@ -1988,6 +1990,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] "); } @@ -115,6 +115,7 @@ struct templateEntry { unsigned bCSV: 1; /* format field in CSV (RFC 4180) format */ unsigned bJSON: 1; /* format field JSON escaped */ unsigned bJSONf: 1; /* format field JSON *field* (n/v pair) */ + unsigned bOptionalField: 1; /* optional field - skip in field template if not present */ } options; /* options as bit fields */ } field; } data; |