mirror of
https://github.com/tstack/lnav.git
synced 2024-09-11 13:05:51 +03:00
[tests] more log samples
This commit is contained in:
parent
5e18f47cd2
commit
4516ffd8d7
@ -33,9 +33,41 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
data_format data_parser::FORMAT_SEMI(DT_COMMA, DT_SEMI);
|
||||
data_format data_parser::FORMAT_COMMA(DT_INVALID, DT_COMMA);
|
||||
data_format data_parser::FORMAT_PLAIN(DT_INVALID, DT_INVALID);
|
||||
data_format data_parser::FORMAT_SEMI("semi", DT_COMMA, DT_SEMI);
|
||||
data_format data_parser::FORMAT_COMMA("comma", DT_INVALID, DT_COMMA);
|
||||
data_format data_parser::FORMAT_PLAIN("plain", DT_INVALID, DT_INVALID);
|
||||
|
||||
data_format_state_t dfs_prefix_next(data_format_state_t state,
|
||||
data_token_t next_token)
|
||||
{
|
||||
data_format_state_t retval = state;
|
||||
|
||||
switch (state) {
|
||||
case DFS_INIT:
|
||||
switch (next_token) {
|
||||
case DT_PATH:
|
||||
case DT_SEPARATOR:
|
||||
case DT_WORD:
|
||||
case DT_SYMBOL:
|
||||
case DT_OCTAL_NUMBER:
|
||||
case DT_HEX_NUMBER:
|
||||
case DT_NUMBER:
|
||||
case DT_WHITE:
|
||||
break;
|
||||
default:
|
||||
retval = DFS_ERROR;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case DFS_ERROR:
|
||||
retval = DFS_ERROR;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
data_format_state_t dfs_semi_next(data_format_state_t state,
|
||||
data_token_t next_token)
|
||||
@ -87,6 +119,7 @@ data_format_state_t dfs_comma_next(data_format_state_t state,
|
||||
case DFS_INIT:
|
||||
switch (next_token) {
|
||||
case DT_COMMA:
|
||||
break;
|
||||
case DT_SEMI:
|
||||
retval = DFS_ERROR;
|
||||
break;
|
||||
@ -103,8 +136,11 @@ data_format_state_t dfs_comma_next(data_format_state_t state,
|
||||
retval = DFS_VALUE;
|
||||
break;
|
||||
|
||||
case DT_SEMI:
|
||||
case DT_COMMA:
|
||||
retval = DFS_INIT;
|
||||
break;
|
||||
|
||||
case DT_SEMI:
|
||||
retval = DFS_ERROR;
|
||||
break;
|
||||
|
||||
@ -119,7 +155,7 @@ data_format_state_t dfs_comma_next(data_format_state_t state,
|
||||
break;
|
||||
|
||||
case DT_SEPARATOR:
|
||||
retval = DFS_VALUE;
|
||||
retval = DFS_ERROR;
|
||||
break;
|
||||
|
||||
default: break;
|
||||
|
@ -129,15 +129,19 @@ enum data_format_state_t {
|
||||
};
|
||||
|
||||
struct data_format {
|
||||
data_format(data_token_t appender = DT_INVALID,
|
||||
data_format(const char *name,
|
||||
data_token_t appender = DT_INVALID,
|
||||
data_token_t terminator = DT_INVALID)
|
||||
: df_appender(appender), df_terminator(terminator)
|
||||
: df_name(name), df_appender(appender), df_terminator(terminator)
|
||||
{};
|
||||
|
||||
const char *df_name;
|
||||
const data_token_t df_appender;
|
||||
const data_token_t df_terminator;
|
||||
};
|
||||
|
||||
data_format_state_t dfs_prefix_next(data_format_state_t state,
|
||||
data_token_t next_token);
|
||||
data_format_state_t dfs_semi_next(data_format_state_t state,
|
||||
data_token_t next_token);
|
||||
data_format_state_t dfs_comma_next(data_format_state_t state,
|
||||
@ -321,14 +325,29 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
if (iter->e_token == DT_SEPARATOR) {
|
||||
if (iter->e_token == this->dp_format->df_terminator) {
|
||||
std::vector<element> key_copy;
|
||||
|
||||
value.splice(value.end(),
|
||||
key_comps,
|
||||
key_comps.begin(),
|
||||
key_comps.end());
|
||||
value.remove_if(element_if(this->dp_format->df_terminator));
|
||||
strip(value, element_if(DT_WHITE));
|
||||
value.remove_if(element_if(DT_COMMA));
|
||||
if (!value.empty()) {
|
||||
el_stack.push_back(element(value, DNT_VALUE));
|
||||
}
|
||||
value.clear();
|
||||
|
||||
key_comps.push_back(*iter);
|
||||
}
|
||||
else if (iter->e_token == DT_SEPARATOR) {
|
||||
element_list_t::iterator key_iter = key_comps.end();
|
||||
bool found = false;
|
||||
|
||||
--key_iter;
|
||||
for (;
|
||||
key_iter != key_comps.begin() && !found;
|
||||
--key_iter) {
|
||||
do {
|
||||
--key_iter;
|
||||
if (key_iter->e_token == this->dp_format->df_appender) {
|
||||
++key_iter;
|
||||
value.splice(value.end(),
|
||||
@ -354,7 +373,7 @@ private:
|
||||
strip(key_comps, element_if(DT_WHITE));
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
} while (key_iter != key_comps.begin() && !found);
|
||||
if (!found && !el_stack.empty() && !key_comps.empty()) {
|
||||
element_list_t::iterator value_iter;
|
||||
|
||||
@ -404,6 +423,8 @@ private:
|
||||
key_comps,
|
||||
key_comps.begin(),
|
||||
key_comps.end());
|
||||
|
||||
value.remove_if(element_if(this->dp_format->df_terminator));
|
||||
strip(value, element_if(DT_WHITE));
|
||||
value.remove_if(element_if(DT_COMMA));
|
||||
if (!value.empty()) {
|
||||
@ -415,7 +436,20 @@ private:
|
||||
while (!el_stack.empty()) {
|
||||
element_list_t::iterator kv_iter = el_stack.begin();
|
||||
if (kv_iter->e_token == DNT_VALUE) {
|
||||
free_row.push_back(el_stack.front());
|
||||
if (pairs_out.empty()) {
|
||||
free_row.push_back(el_stack.front());
|
||||
}
|
||||
else {
|
||||
element_list_t free_pair_subs;
|
||||
struct element blank;
|
||||
|
||||
blank.e_capture.c_begin = blank.e_capture.c_end =
|
||||
el_stack.front().e_capture.c_begin;
|
||||
blank.e_token = DNT_KEY;
|
||||
free_pair_subs.push_back(blank);
|
||||
free_pair_subs.push_back(el_stack.front());
|
||||
pairs_out.push_back(element(free_pair_subs, DNT_PAIR));
|
||||
}
|
||||
}
|
||||
if (kv_iter->e_token != DNT_KEY) {
|
||||
el_stack.pop_front();
|
||||
@ -441,6 +475,19 @@ private:
|
||||
SHA_Update(&context, key_val.c_str(), key_val.length());
|
||||
}
|
||||
|
||||
while (!free_row.empty()) {
|
||||
element_list_t free_pair_subs;
|
||||
struct element blank;
|
||||
|
||||
blank.e_capture.c_begin = blank.e_capture.c_end =
|
||||
free_row.front().e_capture.c_begin;
|
||||
blank.e_token = DNT_KEY;
|
||||
free_pair_subs.push_back(blank);
|
||||
free_pair_subs.push_back(free_row.front());
|
||||
pairs_out.push_back(element(free_pair_subs, DNT_PAIR));
|
||||
free_row.pop_front();
|
||||
}
|
||||
|
||||
++kv_iter;
|
||||
pair_subs.splice(pair_subs.begin(),
|
||||
el_stack,
|
||||
@ -473,6 +520,7 @@ private:
|
||||
while (!free_row.empty()) {
|
||||
switch (free_row.front().e_token) {
|
||||
case DNT_GROUP:
|
||||
case DNT_VALUE:
|
||||
case DT_NUMBER:
|
||||
case DT_SYMBOL:
|
||||
case DT_HEX_NUMBER:
|
||||
@ -539,6 +587,7 @@ private:
|
||||
this->dp_group_token.push_back(DT_INVALID);
|
||||
this->dp_group_stack.resize(1);
|
||||
|
||||
data_format_state_t prefix_state = DFS_INIT;
|
||||
data_format_state_t semi_state = DFS_INIT;
|
||||
data_format_state_t comma_state = DFS_INIT;
|
||||
|
||||
@ -554,8 +603,15 @@ private:
|
||||
assert(elem.e_capture.c_begin != -1);
|
||||
assert(elem.e_capture.c_end != -1);
|
||||
|
||||
prefix_state = dfs_prefix_next(prefix_state, elem.e_token);
|
||||
semi_state = dfs_semi_next(semi_state, elem.e_token);
|
||||
comma_state = dfs_comma_next(comma_state, elem.e_token);
|
||||
if (prefix_state != DFS_ERROR) {
|
||||
if (semi_state == DFS_ERROR)
|
||||
semi_state = DFS_INIT;
|
||||
if (comma_state == DFS_ERROR)
|
||||
comma_state = DFS_INIT;
|
||||
}
|
||||
hist[elem.e_token] += 1;
|
||||
switch (elem.e_token) {
|
||||
case DT_LPAREN:
|
||||
|
@ -55,7 +55,7 @@ static struct {
|
||||
|
||||
{ "sep", pcrepp("(:|=)"),
|
||||
},
|
||||
{ "comm", pcrepp("(,|/)"),
|
||||
{ "comm", pcrepp("(,)"),
|
||||
},
|
||||
{ "semi", pcrepp("(;)"),
|
||||
},
|
||||
@ -98,7 +98,7 @@ static struct {
|
||||
|
||||
{ "word", pcrepp(
|
||||
"([a-zA-Z][a-z']+(?=[\\s\\(\\)!\\*:;'\\\"\\?,]|\\.\\s|$))"), },
|
||||
{ "sym", pcrepp("([^\";\\s:=,/(){}\\[\\]]+)"),
|
||||
{ "sym", pcrepp("([^\";\\s:=,(){}\\[\\]]+)"),
|
||||
},
|
||||
{ "line", pcrepp("(\r?\n|\r|;)"),
|
||||
},
|
||||
|
@ -9,6 +9,9 @@ pair 0:3 ^-^ a=1
|
||||
pair 4:7 ^-^ b=2
|
||||
key 8:9 ^ c
|
||||
num 10:11 ^ 3
|
||||
val 10:11 ^ 3
|
||||
pair 8:11 ^-^ c=3
|
||||
key 12:12 ^
|
||||
num 12:13 ^ 4
|
||||
val 10:13 ^-^ 3,4
|
||||
pair 8:13 ^---^ c=3,4
|
||||
val 12:13 ^ 4
|
||||
pair 12:13 ^ 4
|
||||
|
@ -1,16 +1,29 @@
|
||||
1,2,3,4,five,six,7
|
||||
key 0:0
|
||||
num 0:1 ^ 1
|
||||
val 0:1 ^ 1
|
||||
pair 0:1 ^ 1
|
||||
key 2:2 ^
|
||||
num 2:3 ^ 2
|
||||
val 2:3 ^ 2
|
||||
pair 2:3 ^ 2
|
||||
key 4:4 ^
|
||||
num 4:5 ^ 3
|
||||
val 4:5 ^ 3
|
||||
pair 4:5 ^ 3
|
||||
key 6:6 ^
|
||||
num 6:7 ^ 4
|
||||
val 6:7 ^ 4
|
||||
pair 6:7 ^ 4
|
||||
key 8:8 ^
|
||||
word 8:12 ^--^ five
|
||||
val 8:12 ^--^ five
|
||||
pair 8:12 ^--^ five
|
||||
key 13:13 ^
|
||||
word 13:16 ^-^ six
|
||||
val 13:16 ^-^ six
|
||||
pair 13:16 ^-^ six
|
||||
key 17:17 ^
|
||||
num 17:18 ^ 7
|
||||
val 17:18 ^ 7
|
||||
pair 17:18 ^ 7
|
||||
|
@ -23,9 +23,11 @@ pair 160:165
|
||||
key 168:168 ^
|
||||
key 168:168 ^
|
||||
num 168:174 ^----^ 100003
|
||||
val 168:174 ^----^ 100003
|
||||
pair 168:174 ^----^ 100003
|
||||
key 175:175 ^
|
||||
num 175:176 ^ 1
|
||||
val 175:176 ^ 1
|
||||
pair 175:176 ^ 1
|
||||
grp 168:176 ^------^ 100003,1
|
||||
pair 168:176 ^------^ 100003,1
|
||||
|
@ -1,7 +1,6 @@
|
||||
timstack : TTY=pts/6 ; PWD=/auto/wstimstack/rpms/lbuild/test ; USER=root ; COMMAND=/usr/bin/tail /var/log/messages
|
||||
key 11:14 ^-^ TTY
|
||||
sym 15:18 ^-^ pts
|
||||
num 19:20 ^ 6
|
||||
sym 15:20 ^---^ pts/6
|
||||
val 15:20 ^---^ pts/6
|
||||
pair 11:20 ^-------^ TTY=pts/6
|
||||
key 23:26 ^-^ PWD
|
||||
|
@ -148,11 +148,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
printf("Would you like to update the original file? (y/N) ");
|
||||
fflush(stdout);
|
||||
if (scanf("%3s", resp) == 1 && strcasecmp(resp, "y") == 0) {
|
||||
scanf("%3s", resp);
|
||||
if (strcasecmp(resp, "y") == 0) {
|
||||
rename(TMP_NAME, argv[lpc]);
|
||||
}
|
||||
else{
|
||||
fprintf(stderr, " resp %s\n", resp);
|
||||
retval = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
2013-02-11 06:42:34,310:INFO:com.twisted:Site starting on 8099
|
||||
key 29:29 ^
|
||||
key 29:40 ^---------^ com.twisted
|
||||
pair 29:40 ^---------^ com.twisted
|
||||
key 58:58 ^
|
||||
num 58:62 ^--^ 8099
|
||||
pair 58:62 ^--^ 8099
|
@ -0,0 +1,30 @@
|
||||
Apr 11 16:43:25 localhost smartd[2532]: Device: /dev/sda [SAT], VBOX HARDDISK, S/N:VBc8882b62-a0263a39, FW:1.0, 17.1 GB
|
||||
key 40:46 ^----^ Device
|
||||
path 48:56 ^------^ /dev/sda
|
||||
wspc 56:57 ^
|
||||
key 58:58 ^
|
||||
sym 58:61 ^-^ SAT
|
||||
pair 58:61 ^-^ SAT
|
||||
grp 58:61 ^-^ SAT
|
||||
val 48:61 ^-----------^ /dev/sda [SAT
|
||||
pair 40:61 ^-------------------^ Device: /dev/sda [SAT
|
||||
key 64:64 ^
|
||||
sym 64:68 ^--^ VBOX
|
||||
wspc 68:69 ^
|
||||
sym 69:77 ^------^ HARDDISK
|
||||
val 64:77 ^-----------^ VBOX HARDDISK
|
||||
pair 64:77 ^-----------^ VBOX HARDDISK
|
||||
key 79:82 ^-^ S/N
|
||||
sym 83:102 ^-----------------^ VBc8882b62-a0263a39
|
||||
val 83:102 ^-----------------^ VBc8882b62-a0263a39
|
||||
pair 79:102 ^---------------------^ S/N:VBc8882b62-a0263a39
|
||||
key 104:106 ^^ FW
|
||||
num 107:110 ^-^ 1.0
|
||||
val 107:110 ^-^ 1.0
|
||||
pair 104:110 ^----^ FW:1.0
|
||||
key 112:112 ^
|
||||
num 112:116 ^--^ 17.1
|
||||
wspc 116:117 ^
|
||||
sym 117:119 ^^ GB
|
||||
val 112:119 ^-----^ 17.1 GB
|
||||
pair 112:119 ^-----^ 17.1 GB
|
@ -0,0 +1,13 @@
|
||||
2013-02-11 06:42:34,311:INFO:com.twisted:Starting factory <twisted.web.server.Site instance at 0x1de9290>
|
||||
key 29:29 ^
|
||||
key 29:40 ^---------^ com.twisted
|
||||
pair 29:40 ^---------^ com.twisted
|
||||
key 59:59 ^
|
||||
key 59:59 ^
|
||||
sym 59:82 ^---------------------^ twisted.web.server.Site
|
||||
pair 59:82 ^---------------------^ twisted.web.server.Site
|
||||
key 95:95 ^
|
||||
hex 95:104 ^-------^ 0x1de9290
|
||||
pair 95:104 ^-------^ 0x1de9290
|
||||
grp 59:104 ^-------------------------------------------^ twisted.web.server.Site instance at 0x1de9290
|
||||
pair 59:104 ^-------------------------------------------^ twisted.web.server.Site instance at 0x1de9290
|
Loading…
Reference in New Issue
Block a user