- Notifications
You must be signed in to change notification settings - Fork3
CLI program, that likes json logs and it helps you to like them too
License
foomo/logfrog
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
logfrog
likes json logs, and it helps you to like them too
logfrog
is a cli program that processes json logs line by line from stdin. Those logs typically come from loggers likelogrus,zap,apex orothers, that let you write logs as json objects.
Status: logfrog is very young atm and especially the way we filter is most likely going to change. Despite that it already provides a lot of value, when you are trying to make sense of logs.
Install the latest release of the cli:
$ brew update$ brew install foomo/tap/logfrog
stern -o json -n some-name-space| logfrog -log-type stern
docker-compose logs --no-color -f| logfrog -log-type docker-compose
docker logs some-container2>&1| logfrog
tail -f path-to-file.json| logfrog
logfrog
lets you transform and filter json logs with a javascript function namedfilter
that must be defined in a .js file that is passed with the ar--js-filter
tail -f path-to-file.json| logfrog --js-filter path/to/filter.js
- the js file is executed with the otto vmhttps://github.com/robertkrimen/otto
- it has to contain a filter function like the one below
- the file will be reevaluated, when it changes
- this is highly EXPERIMENTAL and we would love to hear back from you
// filter function must be named filter, it will be reloaded if updated////@param logEntry:{msg?:string;level?:string;time?:string, ...}//@param service:string only set with -log-type docker-compose or stern////@return logEntry | null when null is returned this entry is filtered outfunctionfilter(logEntry,service){// let us look at the service in this naive docker-compose example I butcher the nameswitch(service.substr(0,service.length-2)){case"elasticsearch":// very minimal log entries for elastic searchreturn{level:logEntry.level,msg:logEntry.message};}// log entry manipulation// some date formattinglogEntry.msg=logEntry.msg.substr(0,256);logEntry.time=newDate(logEntry.time).toLocaleString();// trimming a stackif(logEntry.stack){logEntry.stack=logEntry.stack.substr(0,300)+" ...";}// go crazy and have fun ;)returnlogEntry;}
This is an initial set of fields, please let us know what we should add.
msg
<- msg, message, Messagelevel
<- level, Leveltime
<- time, timestamp, Timestamp
- map more fields
- maybe add a web frontend ?!
- stern mode like docker-compose
- add hombrew support
Make a pull request...
Distributed under MIT License, please see license file within the code for more details.
About
CLI program, that likes json logs and it helps you to like them too