0.0.1 • Published 6 years ago

next-bunyan v0.0.1

Weekly downloads
310
License
MIT
Repository
github
Last release
6 years ago

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;
  }
});