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

log-service-lib-otel

v1.0.1

Published

This library provides a logging service with various log levels and features, built on top of the Pino logging library. It allows you to log messages with structured data, manage trace IDs, and create spans for better observability.

Downloads

13

Readme

Log Service Library OTEL

This library provides a logging service with various log levels and features, built on top of the Pino logging library. It allows you to log messages with structured data, manage trace IDs, and create spans for better observability.

Installation

npm install log-service-lib

Usage

Importing the Library

import { createLogger, LogLevel } from 'log-service-lib';

Creating a Logger Instance

You can create a logger instance by using the createLogger function. Specify the accepted log level and optional infrastructure configurations.

const logger = createLogger({
  acceptedLogLevel: LogLevel.info,
});

Logging Messages

The logger supports multiple log levels: trace, debug, info, warn, error, and fatal. Each log level can be used as a method on the logger instance.

logger.info({
  body: 'This is an informational message',
  attributes: { user: 'John Doe' },
});

logger.error({
  body: 'An error occurred',
  attributes: { errorCode: 500 },
});

Managing Trace IDs

You can set and retrieve trace IDs for better traceability.

logger.setTraceId();
console.log(logger.getTraceId()); // Outputs a generated trace ID

logger.setTraceId('custom-trace-id');
console.log(logger.getTraceId()); // Outputs 'custom-trace-id'

Using Spans

Spans allow you to group logs under a specific context. You can create nested spans for hierarchical logging.

const span = logger.getSpan('UserService');
span.info({
  body: 'User service started',
  attributes: { service: 'UserService' },
});

const nestedSpan = span.getSpan('DatabaseQuery');
nestedSpan.debug({
  body: 'Querying database',
  attributes: { query: 'SELECT * FROM users' },
});

Configuration Options

The createLogger function accepts the following options:

  • acceptedLogLevel: The minimum log level to accept (e.g., LogLevel.info).
  • infra.pino: Optional Pino-specific configurations.

License

This library is open-source and available under the MIT License.