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

@hhp1614/log-web

v1.1.3

Published

浏览器日志类

Readme

GitHub license npm version

@hhp1614/log-web

使用 TypeScript 开发的一个浏览器日志打印工具

安装

npm i @hhp1614/log-web

使用

import LogWeb from '@hhp1614/log-web';

const lw = new LogWeb();

lw.info('我是 info 方法');
lw.error('我是 error 方法');

不同打印等级

一共 5 种输出的方法:infoerrorsuccessfaildebug

这 5 中输出方法执行时,默认会把当前设置的 methodprefixtag 清空

如果要保持当前设置的 methodprefixtag 不被清空,请在设置时将第二个参数设置为 true

const lw = new LogWeb();

lw.info('我是 info 方法');
lw.error('我是 error 方法');
lw.success('我是 success 方法');
lw.fail('我是 fail 方法');
lw.debug('我是 debug 方法');

链式调用

遇到这 5 种输出方法(infoerrorsuccessfaildebug)之后,链式调用将终止

简单来说,就是必须以上面的 5 种输出方法结尾,前面不限制调用的数量顺序

const lw = new LogWeb();

lw.method('warn').prefix('前缀').tag('标签').info('我是 info 方法');
lw.info('我是 info 方法');

保存指定使用 console 方法

会覆盖底层使用的默认 console 方法

| 输出方法 | 底层使用的方法 | | ----------- | ----------------- | | info() | console.info() | | error() | console.error() | | success() | console.info() | | fail() | console.error() | | debug() | console.debug() |

.method() 允许设置的方法:"log" | "info" | "warn" | "error" | "debug"

分别对应 console 下的这 5 个方法

const lw = new LogWeb();

const instance = lw.method('warn', true);

instance.prefix('前缀').tag('标签').info('我是 info 方法');
instance.tag('标签').info('我是 info 方法');
instance.info('我是 info 方法');
instance.error('我是 error 方法');
instance.success('我是 success 方法');
instance.fail('我是 fail 方法');
instance.debug('我是 debug 方法');

保存指定前缀

const lw = new LogWeb();

const instance = lw.prefix('hhp', true);

instance.method('warn').tag('标签1').info('我是 info 方法');
instance.tag('标签2').info('我是 info 方法');
instance.info('我是 info 方法');
instance.error('我是 error 方法');
instance.success('我是 success 方法');
instance.fail('我是 fail 方法');
instance.debug('我是 debug 方法');

保存指定标签

const lw = new LogWeb();

const instance = lw.tag('hhp', true);

instance.method('warn').prefix('前缀').info('我是 info 方法');
instance.prefix('前缀').info('我是 info 方法');
instance.info('我是 info 方法');
instance.error('我是 error 方法');
instance.success('我是 success 方法');
instance.fail('我是 fail 方法');
instance.debug('我是 debug 方法');

隐藏打印

初始化时,可以设置隐藏这个实例的所有打印,表现为浏览器控制台没有输出

const lw1 = new LogWeb({ hide: true });
lw1.info('我是隐藏的 info 方法');

const lw2 = new LogWeb({ hide: false });
lw2.info('我是显示的 info 方法');