Docs · Node.js

Node.js logging with alerts, in 5 minutes

Your console.log, pino or winston logs with search, errors with their stack trace, each request's journey and a phone alert when an order never finishes. Without changing how you write them.

  1. 1

    Install

    npm i @estiaje/sdk
  2. 2

    Your key

    Create your account and put the key in ESTIAJE_TOKEN. Or ask your AI “connect this repo to Estiaje” (the connector). Without the key nothing leaves over the network: you can instrument today.

  3. 3

    Your logs, your errors and each request's thread, at startup

    ● Tested in CI
    import { estiajeFromEnv } from '@estiaje/sdk';
    
    export const estiaje = estiajeFromEnv({ service: 'tienda' });
    estiaje.capturarConsola();          // your console.log, as is
    estiaje.capturarErrores();          // uncaught errors
    
    app.use(estiaje.middleware());      // each request's thread
    // … your routes …
    app.use(estiaje.errores());         // last: 5xx errors, with their stack
    // main.ts
    import { estiajeFromEnv } from '@estiaje/sdk';
    
    export const estiaje = estiajeFromEnv({ service: 'tienda' });
    estiaje.capturarConsola();
    estiaje.capturarErrores();
    
    const app = await NestFactory.create(AppModule);
    app.use(estiaje.middleware());      // each request's thread
    import { estiajeFromEnv } from '@estiaje/sdk';
    
    export const estiaje = estiajeFromEnv({ service: 'tienda' });
    estiaje.capturarConsola();
    estiaje.capturarErrores();
    
    fastify.addHook('onRequest', (req, _reply, done) => {
      estiaje.conHilo(req.headers.traceparent as string | undefined, done);
    });
    // a worker, a cron job or a queue
    import { estiajeFromEnv } from '@estiaje/sdk';
    
    export const estiaje = estiajeFromEnv({ service: 'cobros' });
    estiaje.capturarConsola();
    estiaje.capturarErrores();
    
    // with the message's traceparent it continues that thread; without it, starts one
    await estiaje.conHilo(mensaje.traceparent, () => procesar(mensaje));
  4. 4

    The process that must finish

    estiaje.event('order.paid', { order_id, amount });
    // … when it ships …
    estiaje.outcome('order.shipped', { order_id });
  5. 5

    The alert

    In the dashboard, under Processes: “every order.paid expects its order.shipped, by order_id, within 30 minutes”. If it never comes, you get a phone, email or Slack alert, with the money at risk.

And if you want more
  • Your pino or winston logs: estiaje.destino() as one more stream.
  • Your servers: medirServidor() from @estiaje/sdk/servidor: CPU, memory and disk, with an alert before the disk fills up.
  • Your slow database: estiaje.medirConsultas() measures pg and mysql2.
  • Your deploys: npx @estiaje/sdk desplegado in your CI.

Everything else is in the full docs.

The long guide: Node.js logging in production: pino or winston

Create account, 14 days of Pro No card required.