JSPM

winston-transport-browserconsole

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4581
  • Score
    100M100P100Q135951F
  • License ISC

BrowserConsole transport for winston logger.

Package Exports

  • winston-transport-browserconsole

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 (winston-transport-browserconsole) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Winston Transport BrowserConsole

Want to log in browser like using console.log but taking advantage of all facilities winston provides?

Want to filter by level in your browser?

Want to inspect the objects arguments instead of printing them as json strings?

npm install winston-transport-browserconsole -S

And here you have a little sample:

import * as winston from "winston";
import BrowserConsole from 'winston-transport-browserconsole';

const level = "debug";
winston.configure({
    transports: [
        new BrowserConsole(
            {
                format: winston.format.simple(),
                level,
            },
        ),
        // Uncomment to compare with default Console transport
        // new winston.transports.Console({
        //     format: winston.format.simple(),
        //     level,
        // }),
    ],
});

winston.debug("DEBUG ", {a: 1, b: "two"});
winston.debug("DEBUG ", {a: 1, b: "two"});
winston.info("INFO ", {a: 1, b: "two"});
winston.info("INFO ", {a: 1, b: "two"});
winston.warn("WARN", {a: 1, b: "two"});
winston.warn("WARN", {a: 1, b: "two"});
winston.error("ERROR ", {a: 1, b: "two"});
winston.error("ERROR ", {a: 1, b: "two"});

winston.debug("A message alone :'(\n hahaha");
winston.debug("Here examinable Object ", {test: 'test', sub: { object : { test : "here" } } });

Notice Tested with version 3.x.x of winston. Please be sure to set the level in the ConsoleBrowser constructor as did not find a good way to get the one you could configure in winston.