looshis-local-logger v2.0.3
looshis-local-logger
View and filter logs in a browser during local development.
LLL has no dependencies!
Install
npm i -g looshis-local-logger
How To Use
./your-app |& lll
# LLL is ready at: http://localhost:4000 open in browser
Examples
# Pipe standard error in addition to standard output to lll
./your-app |& lll
# Pipe only standard output to lll, ignore standard error
./your-app | lll
# Specify a different port for lll
./your-app | LLL_PORT=1234 lll
# http://localhost:1234
# Run an npm script
npm run start |& lll
# Start a ruby app
ruby ./ruby.rb |& lll
Filtering output
There is an editable javascript function at the top of the browser screen, it must be named "transform" and accepts one argument "logs" which are all of the logs received since the browser has been open. This can be edited to filter, map, and limit the output. Here are some examples:
// Display only logs that contain the string "spinal tap", limit to 11
function transform(logs) {
return logs.slice(-11).filter((log) => {
return log.includes("spinal tap");
});
}
// Display only some nested property of JSON logs
function transform(logs) {
return logs.map((log) => {
try {
return JSON.parse(log).some.nested.property;
} catch (e) {
return "could not parse";
}
});
}
About
lll is a command line utility that serves its stdin to a browser. lll is designed to be used for local development where a lot of logs are being generated and need to be filtered, formatted, copy/pasted, etc.
lll attempts to organize logs visually. Large logs may sometimes span multiple blocks due to size limitations of piping stdin. lll does its best to keep large JSON-stringified logs in tact. Other kinds of large logs may span multiple blocks, but this may be fixed or addressed in the future.
lll has no dependencies and uses only javascript, html, css, and the built in node Test runner.