Compare commits

...

2 Commits

Author SHA1 Message Date
5ebfe7d07b add readme 2025-02-16 21:05:16 +01:00
4597b4be63 removed unused code 2025-02-16 20:58:33 +01:00
2 changed files with 33 additions and 5 deletions

33
README.md Normal file
View 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
```

View File

@ -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';