MatrixAI / js-logger

TypeScript/JavaScript Logger Library
https://polykey.com
Apache License 2.0
1 stars 0 forks source link

Feature log filter #12

Closed CMCDragonkai closed 2 years ago

CMCDragonkai commented 2 years ago

Description

This adds the ability to filter logs based on key path using a regex.

const logger = new Logger('root');
const interLogger = logger.getChild('inter');
const leaf1Logger = interLogger.getChild('leaf1');
const leaf2Logger = interLogger.getChild('leaf2');
logger.setFilter(/^root\.inter/);
leaf1Logger.info('INFO MESSAGE');
leaf2Logger.info('INFO MESSAGE');
logger.setFilter(/^root\.inter\.leaf1/);
leaf1Logger.info('INFO MESSAGE');
leaf2Logger.info('INFO MESSAGE');
logger.setFilter(/^root\.inter\.leaf2/);
leaf1Logger.info('INFO MESSAGE');
leaf2Logger.info('INFO MESSAGE');

This is a simple quick feature, but it doesn't cover the total range of log filtering worth doing. Any complex log filtering should be done on the frontend not on the origin of logs. Discrete data should be captured and filtered down the line.

Issues Fixed

Tasks

Final checklist

ghost commented 2 years ago
👇 Click on the image for a new way to code review - Make big changes easier — review code in small groups of related files - Know where to start — see the whole change at a glance - Take a code tour — explore the change with an interactive tour - Make comments and review — all fully sync’ed with github [Try it now!](https://app.codesee.io/r/reviews?pr=12&src=https%3A%2F%2Fgithub.com%2FMatrixAI%2Fjs-logger)

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map Legend