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 🙏

© 2024 – Pkg Stats / Ryan Hefner

logger-for-cannot-duplicate

v5.0.2

Published

A light logger system for browser for the case which can not duplicate but sometimes happened.

Downloads

10

Readme

logger-for-cannot-duplicate

[ENGLISH] | 中文

A light logger system for browser.

Functions

zero dependence

Log useful info to indexedDB to send to server for analysis Default to use navigator.sendBeacon to upload and not support to fail back to xhr

Usage

Open test.html to experience

import Logger from 'logger-for-cannot-duplicate';

//support more one instances
const logger = new Logger({
  //if isDevEnv is true, it will print console, including logger-for-cannot-duplicate config, default value: false
  isDevEnv: true,
  //indexedDB to put log info, default value: logger-for-cannot-duplicate
  dbName: 'db',
  //your server to receive log infos, default value: ""
  serverAddr: 'put your log server addr here',
  //put package.json info here
  packageInfo: {},
  //upload package usage url, default value: 'https://api-track.kylin.shuyun.com/monitor-service/upload-package-info'
  uploadPackageInfoUrl: '',
  //enable logger, default value: true
  enable: true,
});

//Due to initialize indexedDB is async, so if read or remove or add will return a result named pending
//it's better to instance Logger first and then to use. e.g. init Logger when project launch
//debug level not log to indexedDB
logger.debug('this is debug info');
logger.info('this is info info');
logger.warn('this is warn info');
logger.error('this is error info');
//logger.show will print console even if isDevEnv is false or undefined
logger.show('this is show level info');
//add one log to indexedDB
logger.add('123456');
logger.add(true);
logger.showData();
//read logs in indexDB collection, init indexedDB require some time,
//please wait indexedDB prepare and then call logger method
//other method will save actions to queue and execute util indexedDB init success
logger.read().then(result => {
  console.log('result', result);
  //remove that indexDB collection
  // logger.remove();
  //only clear indexedDB data
  logger.clearData();
  //send log infos to server, also can call send without read
  logger.send(result, 'myLogId');
});

Api

There are nine apis at present and are easy to use.

debug:
Only print info on console when isDevEnv is true, not save to indexedDB

info:
Standard logger print when isDevEnv is true, print info on console and save in indexedDB

warn:
Print warn info on console when isDevEnv is true and save in indexedDB

error:
Print error info on console when isDevEnv is true and save in indexedDB

show:
Print info on console even if isDevEnv is false, and save to indexedDB

showData:
show all data in specify indexedDB collection

log:
Print log info on console when isDevEnv is true and save in indexedDB

add:
Add one log info to indexedDB to save

read:
Read log infos from specify indexedDB

remove:
Remove specify indexedDB database

clearData: clear specify indexedDB database data

send:
Send log infos to your server

CHANGELOG

CHANGELOG

License

MIT