我正在尝试解析流利的盐堆栈状态日志。盐堆栈状态日志如下所示:
ID: paramiko
Function: pip.installed
Name: paramiko == 2.4.2
Result: True
Comment: Python package paramiko == 2.4.2 was already installed
All specified packages are already installed
Started: 18:07:29.968124
Duration: 275.861 ms
Changes:
----------
ID: boto3
Function: pip.installed
Name: boto3 == 1.9.144
Result: True
Comment: Python package boto3 == 1.9.144 was already installed
All specified packages are already installed
Started: 18:07:30.245551
Duration: 276.707 ms
Changes:
我想将所有这些状态解析为一条日志消息,我尝试使用正则表达式和多行。我不确定如何使它正常工作,这是我尝试过的方法
format multiline
format_firstline /^\s+ ID/
format1 /(\s+ ID: (?<id>[^ ]+)\n)?/
format2 /(\s+ Function: (?<function>[^ ]+)\n)?/
format3 /(\s+ Name: (?<name>[^ ]+)\n)?/
format4 /(\s+ Result: (?<result>[^ ]+)\n)?/
format5 /(\s+ Comment: (?<comment>[^ ]+)\n)?/
format6 /(\s+ Started: (?<started>[^ ]+)\n)?/
format7 /(\s+ Duration: (?<duration>[^ ]+)\n)?/
format8 /(\s+ Changes: (?<changes>[^ ]+)\n)?/
即使单独阅读它,也非常感谢您的帮助/指导。