next-bunyan

0.0.1 • Public • Published

Next.js + Bunyan

Use node-bunyan on server side and browser-bunyan on client side in Next.js project

Installation

npm install --save bunyan browser-bunyan next-bunyan

or

yarn add bunyan browser-bunyan next-bunyan

Usage

Create a next.config.js in your project

// next.config.js
const withBunyan = require("next-bunyan");
module.exports = withBunyan();

Create a logger file utils/logger/JsonLogger.js

import bunyan from "bunyan";

export default bunyan.createLogger({
  name: "foo"
  // other bunyan config
});

Then you could use it on another file, for example

import JsonLogger from "utils/logger/JsonLogger.js";

JsonLogger.info("foo bar");

Configuring Next.js

Optionally you can add your custom Next.js configuration as parameter

// next.config.js
const withBunyan = require("next-bunyan");
module.exports = withBunyan({
  webpack(config, options) {
    return config;
  }
});

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i next-bunyan

      Weekly Downloads

      123

      Version

      0.0.1

      License

      MIT

      Unpacked Size

      3.15 kB

      Total Files

      4

      Last publish

      Collaborators

      • khaeransori