connor-base-log
v2.5.0
Published
Base logging library used in a lot of custom projects
Downloads
4
Readme
Connor's Base Log Package
I tend to use this boilerplate package for logging. It automatically sets up Sentry logging and some nice sane defaults for logging with or without a TTY. Designed for use with my default config library.
Install
npm install connor-base-log
How to use
//Assuming you have a config.js boilerplate from my logging lib
//index.js
const config = require('./config'); //This config.js should contain your basic config overwrites like sentry etc.
const log = require('connor-base-log');
log.silly("You may as well just print out every tick", {counter: counter});
log.debug("Okay but you still won't be able to read this");
log.verbose("Eh, this is acceptable in production", {customer_bank_account_no: key});
log.info("A descriptive info which will come up as a breadcrumb on Sentry", {with: extraData});
log.warn("Hm, did you mean to do that? This will show up in Sentry as a warning.", {you: screwedup});
log.error("We're going to spam Sentry with this error");
//Protip: You can set the environment variable LOG_LEVEL to change what shows up in your console.
//config.js
const config = require('connor-base-config');
config.load({sentry: {enabled: true, dsn: "https://sentry.makeshift.ninja/"}});
module.exports = config;
Lazy Template
const config = require('connor-base-config');
config.load({sentry: {enabled: true, dsn: "https://sentry.makeshift.ninja/"}});
const log = require('connor-base-log');
Changing defaults
You can change the options by either:
- Overriding them in config.js
- Requiring connor-base-config and overwriting with .load in-script
- Setting environment variables, you can see a full list in the schema