add readme
This commit is contained in:
parent
4597b4be63
commit
5ebfe7d07b
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
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user