QUESTPIE
Operate in Production

Logger

Structured logging with Pino.

QUESTPIE uses Pino for structured, high-performance JSON logging.

Usage

Access the logger through the context in hooks, routes, jobs, and services:

handler: async ({ logger }) => {
  logger.info("Processing request")
  logger.warn({ userId: "abc" }, "Rate limit approaching")
  logger.error({ err: error }, "Failed to process payment")
}

Log Levels

LevelValueUsage
trace10Verbose debugging (hidden by default)
debug20Development debugging
info30Normal operations (default minimum)
warn40Potential issues, deprecations
error50Errors that need attention
fatal60Critical failures, process should exit

Structured Logging

Pass an object as the first argument for structured data. Pino serializes it as JSON fields:

logger.info(
  {
    appointmentId: "abc",
    action: "created",
    barberId: "def",
    duration: 45,
  },
  "Appointment created",
)

Output (JSON):

{"level":30,"time":1710854400000,"appointmentId":"abc","action":"created","barberId":"def","duration":45,"msg":"Appointment created"}

Child Loggers

Create scoped loggers with persistent context:

const bookingLogger = logger.child({ module: "booking", requestId: "req-123" })
bookingLogger.info("Checking availability")
// → { module: "booking", requestId: "req-123", msg: "Checking availability" }

Error Logging

Use the err key for Error objects — Pino serializes the stack trace:

try {
  await processPayment(orderId)
} catch (error) {
  logger.error({ err: error, orderId }, "Payment processing failed")
}

Configuration

The log level defaults to info. Set it via environment variable:

LOG_LEVEL=debug

Pretty Printing (Development)

In development, pipe output through pino-pretty for human-readable logs:

package.json
{
  "scripts": {
    "dev": "questpie dev | pino-pretty"
  }
}

Production Best Practices

  • Use info level in production (default)
  • Ship JSON logs to your observability platform (Datadog, Grafana, etc.)
  • Use structured fields for queryable metadata
  • Avoid logging sensitive data (passwords, tokens, PII)
  • Use child loggers to add request context automatically

On this page