Compare commits
2 Commits
72bffca489
...
5ebfe7d07b
Author | SHA1 | Date | |
---|---|---|---|
5ebfe7d07b | |||
4597b4be63 |
33
README.md
Normal file
33
README.md
Normal file
@ -0,0 +1,33 @@
|
||||
# LOGFOO
|
||||
Filter and format logfiles on command line
|
||||
|
||||
## build
|
||||
* LUA required ;)
|
||||
```
|
||||
gcc -I/usr/include/lua5.4 -g logfoo.c -llua5.4 -o logfoo
|
||||
```
|
||||
|
||||
## usage
|
||||
```
|
||||
logfoo <path to lua> <path to logfile>
|
||||
```
|
||||
### lua
|
||||
* the lua needs 2 methods
|
||||
* `function filter (line)` returns boolean; true -> don't print line
|
||||
* `function format (line)` returns string
|
||||
* example:
|
||||
```lua
|
||||
function filter (line)
|
||||
-- only lines containing text "Unknown kernel..."
|
||||
return line:find("Unknown kernel command line parameters") == nil
|
||||
end
|
||||
|
||||
function format (line)
|
||||
-- red, bold, underline text "IMAGE"
|
||||
line = line:gsub("(IMAGE)", color("%1", "31;1;4"))
|
||||
-- green text "gentoo"
|
||||
line = line:gsub("(gentoo)", color("%1", "32"))
|
||||
-- only text between "
|
||||
return line:match("\"([^\"]+)\"")
|
||||
end
|
||||
```
|
5
logfoo.c
5
logfoo.c
@ -10,11 +10,6 @@
|
||||
#define EXIT_LOGFILE_HANDLING 2
|
||||
#define EXIT_LUAFILE_HANDLING 3
|
||||
|
||||
// // TODO: assign to lua
|
||||
// #define COLOR_RED 1
|
||||
// #define COLOR_BLUE 2
|
||||
// #define COLOR_GREEN 3
|
||||
|
||||
void trim(char *string) {
|
||||
if (strlen(string) > 0 && string[strlen(string) - 1] == '\n') {
|
||||
string[strlen(string) - 1] = '\0';
|
||||
|
Loading…
x
Reference in New Issue
Block a user