Skip to content
This repository has been archived by the owner on Jan 26, 2020. It is now read-only.
/ gunsen Public archive

Wrapper for Winston appending metadata to messages.

License

Notifications You must be signed in to change notification settings

Seldszar/gunsen

Repository files navigation

Gunsen

Lacerate attackers with two razorsharp warfans.

Wrapper for Winston appending metadata to messages.

Table of Contents

Installation

npm install gunsen --save

Usage

const gunsen = require("gunsen");
const winston = require("winston");

const logger = new gunsen.Logger(
  winston.createLogger({
    format: winston.format.simple(),
    transports: [new winston.transports.Console()],
  }),
);

// Creates a sub-logger with the given metadata
const sub = logger.child({ username: "Seldszar" });

// Outputs: "error: I don't have metadata."
logger.error("I don't have metadata.");

// Outputs: "info: Hello from this user! {"username":"Seldszar"}"
sub.info("Hello from this user!");

// Outputs: "warn: I can also do that! {"date":1529682533839,"username":"Seldszar"}"
sub.log({ level: "warn", message: "I can also do that!", date: Date.now() });

Author

Alexandre Breteau - @0xSeldszar

License

MIT © Alexandre Breteau