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

h5-logutils

v1.0.3

Published

h5日志工具类,可以控制日志输入以及筛选日志

Downloads

6

Readme

欢迎使用 h5-logutils

h5 日志工具类,可以控制日志输出以及方便的筛选日志,不同的等级使用不同的颜色值来区分,日志更加清晰

安装

$ npm install h5-logutils -S

引用示例

直接引用 build/web/h5LogUtils.js 压缩文件

<body>
    <div>web测试日志</div>
    <script src="./build/web/h5LogUtils.js"></script>
    <script>
        //1.获取Log等级枚举对象。
        var logLevelEnum = window.LogUtils.getAllLogLevel();
        console.log(logLevelEnum);
        //2.设置筛选的log等级
        window.LogUtils.setLogLevel(logLevelEnum.WARN);
        //创建app1 log对象
        var app1 = window.LogUtils.create("app:1");
        //3.打印 log 等级日志
        app1.log("log");
        app1.debug("debug");
        app1.info("info");
        app1.warn("warn");
        app1.error("error");
    </script>
</body>

require 方式引入

const LogUtils = require("h5-logutils").default; // commonjs
//1.获取Log等级枚举对象。
const logLevelEnum = LogUtils.getAllLogLevel();
//2.设置筛选的log等级
LogUtils.setLogLevel(logLevelEnum.WARN);
//创建app1 log对象
const app1 = LogUtils.create("app:1");
//3.打印 log 等级日志
app1.log("log");
app1.debug("debug");
app1.info("info");
app1.warn("warn");
app1.error("error");

import 方式引入

import LogUtils from "h5-logutils"; // ES6
//1.获取Log等级枚举对象。
const logLevelEnum = LogUtils.getAllLogLevel();
//2.设置筛选的log等级
LogUtils.setLogLevel(logLevelEnum.WARN);
//创建app1 log对象
const app1 = LogUtils.create("app:1");
//3.打印 log 等级日志
app1.log("log");
app1.debug("debug");
app1.info("info");
app1.warn("warn");
app1.error("error");

用法

LogUtils 是一个日志模块工厂,允许您传入模块名称为不同的模块调试日志。

Example

app.js:

import LogUtils from "h5-logutils"; // ES6
//1.获取全部log等级
const logLevelEnum = LogUtils.getAllLogLevel();
console.log(logLevelEnum);
//2.可以根据开发模式和生产模式,设置全局显示的log等级
LogUtils.setLogLevel(logLevelEnum.WARN);

a.js:

import LogUtils from "h5-logutils"; // ES6
const logA = LogUtils.create("a");
logA.log("log");
logA.debug("debug");
logA.info("info");
logA.warn("warn");
logA.error("error");

b.js:

import LogUtils from "h5-logutils"; // ES6
const logB = LogUtils.create("b");
logB.log("log");
logB.debug("debug");
logB.info("info");
logB.warn("warn");
logB.error("error");

LogUtils 允许您过滤日志

规则 ( "" 显示全部, "-" 隐藏全部, "-a" 隐藏 a, "a,b", 显示 a 和 b, "a,-b",显示 a 隐藏 b)。

Example

a.js:

import LogUtils from "h5-logutils"; // ES6
var logA = LogUtils.create("worker:a");
logA.log("log");
logA.debug("debug");
logA.info("info");
logA.warn("warn");
logA.error("error");

b.js:

import LogUtils from "h5-logutils"; // ES6
var logA = LogUtils.create("worker:b");
logA.log("log");
logA.debug("debug");
logA.info("info");
logA.warn("warn");
logA.error("error");

c.js:

import LogUtils from "h5-logutils"; // ES6
var logB = LogUtils.create("c");
logB.log("log");
logB.debug("debug");
logB.info("info");
logB.warn("warn");
logB.error("error");

app.js:

import LogUtils from "h5-logutils"; // ES6
//1:根据业务名称 worker 过滤日志
LogUtils.enable("worker:*");

//2:显示某些文件日志 "c,worker:a" 过滤日志(模块名称用逗号隔开)
LogUtils.enable("c,worker:a");

//2:排除筛选出来的某一模块的日志 "worker:*,-worker:b" 过滤日志,用逗号隔开( - 用来排除日志)
LogUtils.enable("worker:*,-worker:b");

LogUtils 允许您根据业务需求打印不同的等级日志。

Example

a.js:

import LogUtils from "h5-logutils"; // ES6
var logA = LogUtils.create("worker:a");
// 打印 LOG 日志
logA.log("log");
// 打印 DEBUG 日志
logA.debug("debug");
//打印 INFO 日志
logA.info("info");
//打印 WARN 日志
logA.warn("warn");
//打印 ERROR 日志
logA.error("error");

Authors

  • quanyj