Skip to content

Logging Configuration

Nishant Aanjaney Jalan edited this page Mar 24, 2024 · 6 revisions

Creating the simplest logger

Minimally, there are 3 steps to create your first logger.

  1. Create a Logestic instance.
  2. Define the parameters you wish to use.
  3. Format the string given the parameters. Also see "More on formatting".

Putting the 3 steps together, you get:

import { Logestic } from 'logestic';

const logger = new Logestic() // Step 1
  .use(['method', 'path'])    // Step 2
  .format({                   // Step 3
    onSuccess({ method, path }) {
      return `${method} ${path} was called and handled without server error.`;
    },
    onFailure({ request, error, code }) {
      return `Oops, ${error} was thrown with code: ${code}`;
    }
  })
Clone this wiki locally