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

@yfe/log

v0.2.0

Published

A JavaScript log level module for browser

Downloads

6

Readme

log

log 是一个轻量级浏览器端日志分级模块。

日志分为如下几级

  • debug,级别最低,可以用于任何有利于在调试时了解系统运行状态的信息
  • info,重要,用来反馈当前运行状态
  • warn,警告,可修复,系统可继续执行下去
  • error,错误,可修复,但无法确定系统是否能正常运行
  • fatal,严重错误,无法修复,系统继续运行会产生严重后果

该模块还可将日志发送到指定平台(如log.io)方便测试工程师和非技术人员定位问题和提供信息给技术人员。

Usages

$ npm install --save @yfe/log
import { log } from '@yfe/log';

// 一个项目只在开始设置一次即可
log.setConfig({
    // 设置log发送到哪个日志平台,不设置将不会有发送动作
    logServerUrl: 'http://browser.log.io.server:8008/log'
});

// 调试信息
log.debug('debug');
// 系统运行信息
log.info('info');
// 警告
log.warn('warn');
// 错误
log.error('error');
// 致命错误
log.fatal('fatal');

如上的所有log均会在dev tool打印并发送到 browser.log.io 。

如何设置日志等级

// 设置不打印debug信息
log.setConfig({
    // 此时所有debug信息不打印,会打印info、warn、error、fatal
    level: 'info'
});
// 设置值打印fatal错误和error
log.setConfig({
    // 此时所有debug信息不打印,会打印info、warn、error、fatal
    level: 'error'
});
// 关闭日志打印
log.setConfig({
    // 此时所有debug信息不打印,会打印info、warn、error、fatal
    level: 'off'
});

如何开启线上程序打印日志

建议线上关闭所有日志,但有时需要打开线上日志来调试问题。

log.level预埋了一个点来开启线上日志,只需将window.__log_level设置为相应的日志等级即可。如设置为info,将会打印info、warn、error、fatal日志。

License

Copyright (c) 2018 Linus Wang Licensed under the MIT license.