Frameworks
JavaScript
Pino

Pino

Pino requires that you set up your logger using iudexPino.args.

Install the IUDEX package

npm i iudex

Create a write-only API key 🔑

Click settings in the top left corner of the IUDEX dashboard and create a write-only API key.

Create a write-only API key

Add IUDEX to your code 🚀

Call instrument before instantiating the pino logger. Create your logger using iudexPino.args which will add IUDEX as an output destination for pino.

import { instrument, iudexPino } from 'iudex';
instrument({
  serviceName: 'YOUR_SERVICE_NAME', // Highly encouraged
  publicWriteOnlyIudexApiKey: 'YOUR_PUBLIC_WRITE_ONLY_KEY', // Only ever commit your WRITE ONLY key
  githubUrl: 'GITHUB_URL_TO_YOUR_REPO', // Optional, this sets up code linking
  env: 'production', // Optional, development, local, etc
});
//  ^ place this as high as possible in your code
import pino from 'pino';
 
const logger = pino(...iudexPino.args);

Multiple Destinations

If you have configured pino options or destinations, use iudexPino.options and iudexPino.destination for fine-grained control.

  • iudexPino.options sets the mixin property
  • iudexPino.destination sets the write property
import { instrument, iudexPino } from 'iudex';
instrument({
  serviceName: 'YOUR_SERVICE_NAME', // Highly encouraged
  publicWriteOnlyIudexApiKey: 'YOUR_PUBLIC_WRITE_ONLY_KEY', // Only ever commit your WRITE ONLY key
  githubUrl: 'GITHUB_URL_TO_YOUR_REPO', // Optional, this sets up code linking
  env: 'production', // Optional, development, local, etc
});
import pino from 'pino';
 
const write = str => {
  iudexPino.destination.write(str);
  console.log(str);
};
const logger = pino(iudexPino.options, { write });

Set up Slack alerts 📣

Click the Slack logo in the top right of the dashboard and follow the prompts.

Slack integration button

Note: you must have admin permissions to add apps to your workspace.

Create a log 🪵

Add code to emit a log.

logger.info({ 'iudex.slack_channel_id': 'YOUR_SLACK_CHANNEL_ID' }, 'Hello IUDEX!');

Then run your code to emit the log.

Verify 🧐

You should see the log in Slack and in your IUDEX dashboard log view.

Slack message

Log in IUDEX

Go in-depth 👉

Check out more in-depth guides on how to get the most out of IUDEX for your stack.