An introduction to Pino

How do I find new software or tools to use? I observe everybody I know using it until I finally think to myself, 'I should check that out.' That's how I found Pino.

Tim E

Tim E

October, 2024

Man looking at a laptop

Pino is a pretty slick little library for logging. That's it. But as you can imagine, logging is kind of a big deal for us at EventScout. It's part of our DNA. So when I started noticing more and more people using Pino, I had to check it out for myself.

To give you the full spiel, Pino is a fast, lightweight, and feature-rich logging library designed specifically for Node.js. Developed with a focus on speed, low overhead, and flexibility, Pino offers developers a modern logging solution that addresses the performance issues often found in traditional logging libraries.

Ever have a situation where you find things are a little slow, a little sluggish, so you check out your performance trace and see that 99% of your time is spent on the logging service (*cough* Cloudwatch *cough*)? No? Well I have, and I wish I had found Pino then. Im sometimes guilty of just npm install-ing the first thing I see, or even things that are just 'how things have always been done', without giving much thought to it, and so I hadnt really thought much about the logging libraries or services that I was using. I never thought logging would be the thing to have so much impact. Anyway, thats how I found myself looking into Pino.

Why Pino?

Pino is fast. Checkout their benchmarks if you don't believe me. How does it achieve this? Firstly, it focuses on low overhead. This is important because Log messages tend to get added over time and this can lead to a throttling effect on applications, such as reduced requests per second.

Additionally, because Node is single-threaded, logging can block the event loop, leading to performance issues. Pino uses separate processes that it calls 'Transports' to handle things like sending, alerting and reformatting, so the main process can continue to run without being blocked.

Pino is also lightweight. It has a small memory footprint and a minimal number of dependencies, making it a great choice for applications where memory usage is a concern.

Pino is also highly configurable, allowing developers to customize the log output to suit their needs. For example thepino-pretty module can be used to format logs in a human-readable way.

How to use Pino

Using Pino is pretty straightforward. To get started, install the Pino package from npm:

npm install pino
Then, require the Pino module in your application and create a new logger instance:
const pino = require('pino');
const logger = pino();
You can then use the logger instance to write logs to the console:
logger.info('This is an info message');
logger.warn('This is a warning message');
logger.error('This is an error message');
Pino also supports a bunch of other stuff like log levels, log rotation, log filtering, and log redaction. For more information on how to configure Pino, check out the Pino docs.

So there you have it. This is not an ad for Pino, I promise. I just really appreciate good software when I find it. Pino is fast, lightweight, and feature-rich. It offers developers a modern logging solution that addresses the performance issues often found in traditional logging libraries. If you're looking for a logging library that is fast, lightweight, and highly configurable, Pino is definitely worth checking out.


Get started with EventScout

Simple web and product analytics with AI powered insights. Get started with EventScout today.