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

lego-logger

v1.0.31

Published

Logging solution for applications

Readme

Lego Logger

A lightweight and flexible logging library, part of a solution developed for Corebiz clients. lego-logger allows you to register events, errors, and other important information in your VTEX applications, integrating with a backend API for centralized log storage.


✨ Features

  • Supports multiple log levels: info, success, warn, error, debug
  • Dynamically generates the API URL based on the VTEX account and workspace
  • Easy integration with VTEX apps and environments
  • Securely sends logs using a clientKey for authentication
  • Flexible and extensible for various use cases

📦 Installation

Install the library via npm or yarn:

npm install lego-logger
# or
yarn add lego-logger

🚀 Usage

1. Import the library

import { Logger } from 'lego-logger'

2. Configure the Logger

Instantiate the logger with the following parameters:

  • clientKey: A unique key provided for each client
  • account: The VTEX account name
  • workspace: The VTEX workspace name

The API URL is dynamically generated based on these parameters.

const CLIENT_KEY = 'your-client-key'
const ACCOUNT = 'your-account'
const WORKSPACE = 'your-workspace'

const logger = new Logger(CLIENT_KEY, ACCOUNT, WORKSPACE)

3. Log events

Use the logger methods to register events at different levels:

// Success log
await logger.success({
  message: 'User successfully logged in',
  identifyid: 'example'
  payload: { data: 'example' },
  response: { data: 'example' }
  additionaldata: { data: 'example' }
})

// Error log
await logger.error({
  message: 'Failed to fetch user data',
  identifyid: 'example'
  payload: { data: 'example' },
  response: { data: 'example' }
  additionaldata: { data: 'example' }
})

📚 API Reference

Constructor

new Logger(clientKey: string, account: string, workspace: string)

Parameters:

  • clientKey (string): Unique client identification key
  • account (string): VTEX account name
  • workspace (string): VTEX workspace name

Methods

1. success(params: LogParams)

Logs a success event.

2. info(params: LogParams)

Logs an informational event.

3. warn(params: LogParams)

Logs a warning.

4. error(params: LogParams)

Logs an error.

5. debug(params: LogParams)

Logs a debug event.


🔧 LogParams

Object with the following fields:

| Field | Type | Description | |------------------|----------|--------------------------------------------------| | message | string | Main log message (required) | | identifyid | string | Optional identifier | | payload | any | Object Payload data | | response | any | Object Response data | | additionaldata | any | Object with extra information |


🌐 Dynamic API URL

The API URL is dynamically generated based on the given account and workspace:

const logger = new Logger('client-key', 'account', 'workspace')
// Generates the URL:
https://workspace--account.myvtex.com/_v/logs/register

❗ Important Notes

Make sure the endpoint is accessible — this requires the Admin App Lego-Logger to be properly installed in your VTEX account.

Ensure the provided clientKey is valid and active.

If the log fails to send due to network issues or server errors, a message will appear in the console:

Error sending log: Failed to send log to API.

📬 Support

For questions or support, contact: email