Reminder:
Since 3.0-dev4, we can optionally give a name to logformat nodes:
log-format "%(custom_name1)B %(custom_name2)[str(value)]"
But we may also optionally set the expected node type by appending
':type' after the name, type being either sint,str or bool, like this:
log-format "%(string_as_int:sint)[str(14)]"
However, it is currently not possible to provide a type without providing
a name that is a least 1 char long. But it could be useful to provide a
type without setting a name, like this, for typecasting purposes only:
log-format "%(:sint)[bool(true)]"
Thus in order to allow this usage, don't set node->name if node name is
not at least 1 character long. By doing so, node->name will remain NULL
and will not be considered, but the typecast setting will.
node->type = LOG_FMT_TAG;
node->tag = &logformat_tags[j];
node->typecast = typecast;
- if (name)
+ if (name && name_len)
node->name = my_strndup(name, name_len);
node->options = lf_expr->nodes.options;
if (arg_len) {
memprintf(err, "out of memory error");
goto error_free;
}
- if (name)
+ if (name && name_len)
node->name = my_strndup(name, name_len);
node->type = LOG_FMT_EXPR;
node->typecast = typecast;