bunway
    Preparing search index...

    Function logger

    • Request logging middleware similar to morgan

      Parameters

      • Optionalformat: string | FormatFn

        Predefined format name ('combined', 'common', 'dev', 'short', 'tiny') or custom format string using tokens like :method :url :status or custom format function

      • options: LoggerOptions = {}

        Logger options

      Returns Handler

      // Using predefined format
      app.use(bunway.logger('dev'));
      // Using custom format string
      app.use(bunway.logger(':method :url :status :response-time ms'));
      // Using custom format function
      app.use(bunway.logger((tokens, req, res, meta) => {
      return `${req.method} ${req.path} ${res.statusCode} ${meta.responseTime}ms`;
      }));
      // With options
      app.use(bunway.logger('combined', {
      skip: (req) => req.path === '/health',
      stream: { write: (msg) => Bun.write('access.log', msg, { append: true }) }
      }));