1

これが私を悩ませているものです:

次のような特定の形式で記述されたログファイルがあります。

[DEBUG    7] 2012-06-12 09:26:37.847 [MOD: UNK/0 ] [FILE:ModuleManager.cpp:541] [FUNC: ModuleManager::handleStatusRequestMessage] [MSG:Got request for unsupported ALLOCATION_STATUS ]

したがって、ブロックはかなりよく分離されています。私はこのログを80x25のターミナル画面で尾から見ていますが、ひどいように見えます(いいえ、画面を変更できません。組み込みデバイスです)。

次のようなものを実現するために、tail / awk(または同様の)の組み合わせを作成するのを手伝ってもらえますか?

2012-06-12 09:26:37.847 Got request for unsupported ALLOCATION_STATUS

また

2012-06-12 09:26:37.847 ModuleManager::handleStatusRequestMessage - Got request for unsupported ALLOCATION_STATUS

また

2012-06-12 09:26:37.847 ModuleManager.cpp:541 ModuleManager::handleStatusRequestMessage - Got request for unsupported ALLOCATION_STATUS

上記の長蛇の列から?

ありがとう

4

2 に答える 2

2
$ awk -F '[][]' '{print $3, $10}' logfile
2012-06-12 09:26:37.847  MSG:Got request for unsupported ALLOCATION_STATUS
$ awk -F '[][]' '{print $3, $8, $10}' logfile
 2012-06-12 09:26:37.847  FUNC: ModuleManager::handleStatusRequestMessage MSG:Got request for unsupported ALLOCATION_STATUS
$ awk -F '[][]' '{print $3, $6, $8, $10}' logfile
 2012-06-12 09:26:37.847  FILE:ModuleManager.cpp:541 FUNC: ModuleManager::handleStatusRequestMessage MSG:Got request for unsupported ALLOCATION_STATUS

また

$ awk -F '[][]|MOD:|FUNC:|FILE:|MSG:' '{print $3, $8, $11 " - " $14}' inputfile
2012-06-12 09:26:37.847  ModuleManager.cpp:541  ModuleManager::handleStatusRequestMessage - Got request for unsupported ALLOCATION_STATUS
于 2012-06-12T10:04:02.417 に答える
1

sed私は根本的なフォーマットの一掃を提案します:

tailf -f logfile | sed -e 's/\[MSG:\([^]]*\)\]/\1/' -e 's/\[[^]]*\] *//g'
于 2012-06-12T09:55:51.113 に答える