Package Exports
- debug-symbols
- debug-symbols/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (debug-symbols) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Motivation
I built this small module because I wanted to use the popular debug module but extend it to:
- Handle different log levels out of the box
- Use colorization for different log levels (using chalk )
- Add the amazing log-symbols symbols to logs.
Usage
This module merely extends Debug's usage and leaves all else intact.
const logger = require("debug-symbols")("namespace");
// Extend logger, Internally does debug.extend()
logger.extend("extend-to");
// This runs debug() as you might expect
logger.log("Default usage");
// Adding various log levels...
logger.debug("debug");
logger.info("info");
logger.warn("warn");
logger.error("error");
logger.fatal("fatal");
logger.fail("failed");
logger.success("success");This will log something like this:
Default Namespaces
When working with a large project, you might want to have a default main namespace.
For example.
For Example:
Assume my project is called
aws-serverI would want all scripts usingdebug-symbolsto have their namespace asaws-server:script-name
The default namespace in this case is aws-server. Instead of repeating it in every script, I can set it globally using the environment variable DEBUG_NS and each module will adopt it.
In this case:
- The namespace
expressbecomesaws-server:express. - The namespace
aws-server:admin-routeremainsaws-server:admin-route.
So to show my logs, all I need is add process.env.DEBUG="aws-server* and all my scripts will log as expected.