Settings
Ordering direction
By default the new log entries appear at the top. You can change that direction in the settings under Order of entries
.
Maximum number of log messages stored
Specifies a maximum number of messages that will be kept in memory. You can dynamically adjust that limit.
Middlewares
A middleware is a piece of code that can process a log line and decide whether to pass it to the next middleware or not. Middlewares allow you to build custom format parsing and filtering.
Basic middleware looks like below:
(line: Message): Message | void => {
return line;
}
The middleware has to return a Message
type of void
, in the case of void
, next middlewares will not be invoked and the log line will be discarded (it will not show up in the table).
The below example presents filtering capabilities:
(line: Message): Message | void => {
if(line.content.includes('noise')){
// every log line that contain 'noise' string will not be passed
return
}
return line;
}
The below example presents transformation capabilities, you can mask sensitive data for example
(line: Message): Message | void => {
if(line.json_content.last_name){
// masking PII
line.json_content.last_name = line.json_content.last_name.substring(0, 3)+"..."
}
return line;
}
Another more powerful feature of a middleware is parsing. You can build a custom raw text parser that will transform into a JSON that's easily readable by the code responsible for displaying columns. The below code will parse Apache Webserver logs into JSON.
(line: Message): Message | void => {
let [ ip, i1, i2, ts, tz, method, resource, protocol, statusCode, size, referer, ...userAgent ] = line.split(' ');
statusCode = +statusCode;
size = +size;
ts = ts.substring(1);
tz = tz.substring(0, tz.length - 1);
const time = ts + tz;
userAgent = userAgent.join('');
line.json_content = { ip, time, method, resource, protocol, statusCode, size, referer, userAgent }
return line;
}
Middlewares - order key for logs
You can now emit an order_key
for every message in a Middleware. order_key
is used to order log messages in a table by that property. This is especially useful if you're digesting data from multiple sources at once. For each message you can for example parse a timestamp then emit a unix timestamp (or other sortable data) in order_key
. Logs presented in a table together will sorted in ascending order by the contents of order_key
.
Export layout settings
You can export layout settings, columnd defined with the code and middlewares. That enables portability between multiple hosts or users.
Go to Settings > Import/Export. You can export layout settings by downloading a file or copying the settings right to the clipboard.
Import layout settings
Go to Settings > Import/Export. You can import layout settings by pasting previously exported setting or uploading a file.
TIP
You can import layout settings using a file stored on a disk by providing a CLI option.