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

@~lisfan/logger

v1.3.4

Published

调试日志打印器

Downloads

5

Readme

logger

日志打印器

API documentation

Feature 特性

  • 解决提交时因eslint提示console的语句无法通过问题
  • 仅在开发环境打印日志,生产环境不打印日志

Detail 详情

  • 在console上包装了一层,支持console的所有的方法(包含部分非标准APi,但不包含未被废弃的API),部分API做了变化和新增加,未提及的保原效果不变,只是在原api上封装了一层进行代理运行,API使用方法可以参考console API
    • 新增的isActivated、color、enable、disable方法
    • 调整error方法的作用:打印时会抛出错误,阻止脚本执行
    • 调整table方法的作用:如果数据非array或object类型,则使用this.log打印
  • 若需要在生产环境下调式日志,可以更改或设置LS离线存储的值
    • localStorage设置IS_DEV为true
    • localStorage设置LOGGER_RULES配置命名空间规则
  • 支持配置整个命名空间是否输出日志
  • 支持配置命名空间下某个实例方法是否输出日志

Install 安装

npm install -S @~lisfan/logger

Usage 起步

import Logger from '@~lisfan/logger'

// 配置规则
Logger.configRules({
   request:true, // 该命名空间支持打印输出
   request.error:false, // 该命名空间下的error方法不支持打印输出
   response:false // 该命名空间不支持打印输出
})

const logger = new Logger() // 默认打印器,命名空间为`logger`
const loggerRequest = new Logger('request') // 创建命名空间为`request`的打印器
const loggerResponse = new Logger('response')

// 创建打印器,但关闭调试功能
const loggerDebug = new Logger({
   name: 'debug',
   debug: false
})

loggerRequest.log('请求url')    =>    [request]: 请求url
loggerRequest.error('请求url')    =>    // 无内容打印
loggerResponse.error('响应数据')    =>    // 无内容打印
loggerDebug.log('请求url')    =>     // 无内容打印