Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/khaeransori/next-pino
Use pino on server and client side in Next.js project
https://github.com/khaeransori/next-pino
Last synced: 3 months ago
JSON representation
Use pino on server and client side in Next.js project
- Host: GitHub
- URL: https://github.com/khaeransori/next-pino
- Owner: khaeransori
- License: mit
- Created: 2018-03-09T16:27:02.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-11T12:44:51.000Z (almost 7 years ago)
- Last Synced: 2024-09-18T23:15:01.852Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 12
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
- awesome - khaeransori/next-pino - Use pino on server and client side in Next.js project (JavaScript)
README
# Next.js + Pino
Use [pino](https://github.com/pinojs/pino) on server and client side in Next.js project
## Installation
```bash
npm install --save pino next-pino
```or
```bash
yarn add pino next-pino
```## Usage
Create a `next.config.js` in your project
```js
// next.config.js
const withPino = require("next-pino");
module.exports = withPino();
```Create a logger file `utils/logger/JsonLogger.js`
```js
import pino from "pino";export default pino()({
// usual pino config
});
```Then you could use it on another file, for example
```js
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
```js
// next.config.js
const withPino = require("next-pino");
module.exports = withPino({
webpack(config, options) {
return config;
}
});
```