You need to enable JavaScript to run this app.
Torch Log Service

Torch Log Service

Copy page
Download PDF
Global operation function
Field check function
Copy page
Download PDF
Field check function
This topic describes the syntax and format of field validation functions, as well as relevant scenario examples.​
f_has function​
Checks whether the specified field exists.​
Function syntax/format​
​
f_has(field)​
​
The parameters are described below:​
​
Parameters​
Parameter type​
Required​
Default value​
Value range​
Description​
field​
String​
Yes​
/​
/​
Checks whether a field name exists.​
​
Function examples​
  • Scenario: Checks whether the msg field exists in logs. If it exists, a new field status is added.​
  • Processing rules:​
  • ​
    c_if(f_has("msg"), f_set("status", "200"))​
    ​
  • Log example​
  • ​
    {​
    "log-level":"INFO",​
    "msg":"hello"​
    }​
    ​
  • Processing result:​
  • ​
    {​
    "log-level":"INFO",​
    "msg":"hello",​
    "status":"200"​
    }​
    ​
f_not_has function​
Determine whether the specified field does not exist.​
Function syntax/format​
​
f_not_has(field)​
​
The parameters are described below:​
​
Parameters​
Parameter type​
Required​
Default value​
Value range​
Description​
field​
String​
Yes​
/​
/​
Check whether the field name does not exist.​
​
Function examples​
  • Scenario: Checks whether the log-level field exists in the log. If not, a new field status is added.​
  • Processing rules:​
  • ​
    c_if(f_not_has("log-level"), f_set("status", "400"))​
    ​
  • Log example​
  • ​
    [​
    {​
    "log-level":"DEBUG",​
    "msg":"hello"​
    },​
    {​
    "msg":"world"​
    }​
    ]​
    ​
  • Processing result:​
  • ​
    [​
    {​
    "log-level":"DEBUG",​
    "msg":"hello"​
    },​
    {​
    "msg":"world",​
    "status":"400"​
    }​
    ]​
    ​
​
Last updated: 2026.05.13 18:00:38