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

@lalamove/web-logger

v0.10.0

Published

A logger Javascript SDK for Lalamove web project.

Readme

@lalamove/web-logger Build Status Coverage Status

A logger Javascript SDK to send client side errors or logs to custom logging services, based on Lalamove's log format.

Install

yarn add @lalamove/web-logger

Usage

Modules

Create a file to init the logger:

import Logger from '@lalamove/web-logger';

// Init config
// Will auto catch window.onerror to logging services after init, in `fatal` level
const log = new Logger({
    url: 'https://log.dev.lalamove.com', // Logging services URL, required
    key: 'API_KEY', // Credential key, required
    release: '2.0.0', // Product version, required
    locale: 'zh_HK', // required
    location: 'HK_HKG', // required
    environment: 'test', // Environment, required
    platform: 'webapp', // required
    appType: 'user' // required
});

export default log;

Then you can use it with import:

import log from './log';

// Custom log message
log.info('testing message');

React Error Boundaries

Read here for more details of Error Boundaries in React.

Create a component called ErrorBoundary:

import { Component } from 'react';
import log from './log';

export default class ErrorBoundary extends Component {
  static componentDidCatch(error, info) {
    const errorMessage = error.toString();
    log.error(errorMessage, null, info.componentStack);
  }

  render() {
    return this.props.children;
  }
}

Then you can use it as a regular component:

<ErrorBoundary>
  <BlahBlahBlah />
</ErrorBoundary>

Old-school way

Your application should get the build from node_modules/@lalamove/web-logger/index.iife.js (after yarn), and add it in the <head>.

<script src="node_modules/@lalamove/web-logger/index.iife.js"></script>
<script>
// Init config
// Will auto catch window.onerror to logging services after init
var log = new Logger({
    url: 'https://log.dev.lalamove.com', // Logging services URL, required
    key: 'API_KEY', // Credential key, required
    release: '2.0.0', // Product version, required
    locale: 'zh_HK', // required
    location: 'HK_HKG', // required
    environment: 'test', // Environment, required
    platform: 'webapp', // required
    appType: 'user' // required
});

// Custom log message
log.info('testing message');
</script>

API

changeLogLevels()

Updates the log levels to call or suppress. Accepts an array of strings. Levels that are not included will be suppressed and not logged. During initialization, all five levels are included (debug, info, warning, error, fatal).

const defaultLevels = ['debug', 'info', 'warning', 'error', 'fatal'];
log.changeLogLevels(['info', 'warning', 'error', 'fatal']); // will suppress log.debug()

changeUrl()

Change URL in config.

log.changeUrl('https://log.test.lalamove.com');

changeLocation()

Change location in config.

log.changeLocation('TW_TPE');

changeLocale()

Change locale in config.

log.changeLocale('zh_TW');

changeClientId()

Change client id in config.

log.changeClientId('20');

info()

Custom info log.

log.info('blahblahblah');

// Destructuring the object in second argument to context when sending data to logging services
log.info('blahblahblah', { customKey: 'message' });

debug()

Custom debug log.

log.debug('blahblahblah');

// Destructuring the object in second argument to context when sending data to logging services
log.debug('blahblahblah', { customKey: 'message' });

warning()

Custom warning log.

log.warning('blahblahblah');

// Destructuring the object in second argument to context when sending data to logging services
log.warning('blahblahblah', { customKey: 'message' });

error()

Custom error log.

log.error('blahblahblah');

// Destructuring the object in second argument to context when sending data to logging services
log.error('blahblahblah', { customKey: 'message' });

// Custom error stack trace string
log.error('blahblahblah', { customKey: 'message' }, 'Error: error message↵ at Home._this.render(https://blah.com/index.js:1:1)');

fatal()

Custom fatal log.

log.fatal('blahblahblah');

// Destructuring the object in second argument to context when sending data to logging services
log.fatal('blahblahblah', { customKey: 'message' });

// Custom error stack trace string
log.fatal('blahblahblah', { customKey: 'message' }, 'Error: error message↵ at Home._this.render(https://blah.com/index.js:1:1)');

Features

Log format

The output of the log will be posted to the logging services in the JSON format below:

{
    "message": "", // Describing what happened
    "src_file": "", // File path
    "src_line": "", // Line number
    "context": {
        "agent": "", // navigator.userAgent
        "environment": "",
        "locale": "",
        "location": "",
        "platform": "",
        "app_type": "",
        "release": "",
        "client_id": "",
        "url": "", // window.location.href
        // Destructuring custom context here
    },
    "level": "", // Log level: debug/info/warning/error/fatal
    "time": "", // ISO8601.nanoseconds+TZ
    "backtrace": "" // Error stack
}

Run Tests

yarn test

Browsers Support

We use window.fetch to send out network request to custom logging services. If you would like to support older browsers, you need to import github/fetch and taylorhakes/promise-polyfill.

  • Chrome
  • Firefox
  • Safari
  • Edge

License

Report issues / Support