npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

reklog-request

v0.0.22

Published

Request logging library for tracking API response times and performance

Readme

npm install reklog-request

or

yarn add reklog-request

Getting API Key

  1. Sign up at reklog.com
  2. Create a new project
  3. Copy your API key (starts with rkl_)

Usage

Initialize

const reklog = require('reklog-request');

const logger = reklog.init('rkl_your_api_key', {
  environment: 'production',
  host: 'https://api.example.com',
  debug: false
});

Manual Logging with start() and end()

Track external API calls or custom operations:

async function fetchUsers() {
  const logId = logger.start('/api/users', 'GET');

  try {
    const response = await fetch('https://api.example.com/users');
    const data = await response.json();

    await logger.end(logId, {
      statusCode: response.status,
      params: { page: 1, limit: 10 },
      response: data
    });

    return data;
  } catch (error) {
    await logger.end(logId, {
      statusCode: 500,
      metadata: { error: error.message }
    });
    throw error;
  }
}

Express Middleware

Automatically log all requests:

const express = require('express');
const reklog = require('reklog-request');

const app = express();
app.use(express.json());

const logger = reklog.init('rkl_your_api_key');
app.use(logger.middleware());

app.get('/api/users', (req, res) => {
  res.json({ users: [] });
});

app.listen(3000);

API Reference

init(apiKey, options)

Initialize RekLog instance.

| Option | Type | Default | Description | |--------|------|---------|-------------| | apiKey | string | required | Your RekLog API key | | apiUrl | string | https://api.reklog.com/api | API endpoint URL | | environment | string | development | Environment name | | host | string | null | Host identifier for requests | | debug | boolean | false | Enable debug logging | | retryAttempts | number | 3 | Retry attempts on failure | | retryDelay | number | 1000 | Delay between retries (ms) | | maskFields | array | [] | Fields to mask in logs | | excludeEndpoints | array | [] | Endpoints to exclude from logging |


Excluding Endpoints from Logging

You can exclude specific endpoints from being logged using the excludeEndpoints option. This works for both middleware and manual logging (start()/end()).

This is useful for:

  • Health check endpoints
  • Static file requests
  • Internal monitoring endpoints
  • Any endpoints that don't need logging

Basic Usage

const logger = reklog.init('rkl_your_api_key', {
  excludeEndpoints: ['/health', '/ping', '/metrics']
});

// Works with middleware
app.use(logger.middleware());

// Also works with manual logging
const logId = logger.start('/health', 'GET'); // Returns null, won't log
await logger.end(logId); // Safely ignores null logId

Wildcard Patterns

Use * to match multiple endpoints:

const logger = reklog.init('rkl_your_api_key', {
  excludeEndpoints: [
    '/health',           // Exact match
    '/api/internal/*',   // All endpoints starting with /api/internal/
    '/static/*',         // All static file requests
    '*/ping'             // Any endpoint ending with /ping
  ]
});

Examples

// Exclude health checks and static files
const logger = reklog.init('rkl_your_api_key', {
  excludeEndpoints: ['/health', '/ready', '/static/*', '/assets/*']
});

// Exclude admin and internal endpoints
const logger = reklog.init('rkl_your_api_key', {
  excludeEndpoints: ['/admin/*', '/internal/*', '*/debug']
});

// Combine with other options
const logger = reklog.init('rkl_your_api_key', {
  environment: 'production',
  debug: false,
  maskFields: ['password', 'token'],
  excludeEndpoints: ['/health', '/metrics', '/static/*']
});

Note: Excluded endpoints will not appear in your RekLog dashboard and won't count towards your request quota.


Data Privacy & Field Masking

RekLog can mask sensitive data to protect user privacy and comply with data protection regulations. Sensitive field values are replaced with ******** before being sent to the server.

Configuring Fields to Mask

Use the maskFields option to specify which fields should be masked:

const logger = reklog.init('rkl_your_api_key', {
  maskFields: ['password', 'token', 'secret', 'api_key', 'credit_card', 'cvv', 'ssn']
});

How It Works

Field masking is:

  • Case-insensitive: Password, PASSWORD, and password are all masked
  • Recursive: Works on nested objects at any depth
  • Applied to: body, params, requestHeaders, and response

Example

Original Request Body:

{
  "email": "[email protected]",
  "password": "secret123",
  "profile": {
    "name": "John Doe",
    "pin": "1234"
  }
}

Logged Data (with maskFields: ['password', 'pin']):

{
  "email": "[email protected]",
  "password": "********",
  "profile": {
    "name": "John Doe",
    "pin": "********"
  }
}

Note: The masking happens on the client side before data is sent to RekLog servers, ensuring sensitive data never leaves your application.

start(endpoint, method)

Start tracking a request.

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | endpoint | string | required | Endpoint path | | method | string | GET | HTTP method |

Returns: logId (string)

end(logId, options)

End tracking and send log to server.

| Option | Type | Default | Description | |--------|------|---------|-------------| | logId | string | required | Log ID from start() | | statusCode | number | 200 | HTTP status code | | body | object | null | Request body (POST/PUT/PATCH) | | params | object | null | Query parameters (GET) | | requestHeaders | object | null | Request headers | | response | object | null | Response data | | metadata | object | {} | Additional custom data |

middleware()

Returns Express middleware for automatic logging.

app.use(logger.middleware());

Automatically captures:

  • Endpoint and method
  • Response time
  • Status code
  • Request body, query params, headers
  • Response body
  • Route parameters

License

MIT