MINOR: log: skip custom logformat_node name if empty
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.
This commit is contained in:
parent
c584600083
commit
d3c92a3a83
@ -421,7 +421,7 @@ static int parse_logformat_tag(char *arg, int arg_len, char *name, int name_len,
|
||||
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) {
|
||||
@ -523,7 +523,7 @@ static int add_sample_to_logformat_list(char *text, char *name, int name_len, in
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user