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

vk-log

v1.0.5

Published

## 背景 移动端项目如何快速定位线上上线项目出现的各种异常 ## 项目上线的一些限制

Readme

前端日志记录

背景

移动端项目如何快速定位线上上线项目出现的各种异常

项目上线的一些限制

  • 线上代码压缩合并
  • 服务器无法上传.sourcemap文件
  • 线上项目会把console.log全部干掉
  • 移动端没有调试工具

解决(分模块记录日志)

导入vk-lcloger模块正确方法和使用:
import {getLogInstance,VKConsole} from 'vk-log';

// 获取日志对象
let bugout = getLogInstance('vk-a')
// 记录日志
bugout.log('xxx')
bugout.log('000')
bugout.log(new Date())

let bugout2 = getLogInstance('vk-b')
bugout2.log('vipkid log...');

// 显示日志面板
VKConsole.getInstance().init()

// 获取所有模块日志
window.getLogModule()
// 获取'vk-a'模块日志
window.getLogModule('vk-a').getLog()
引用vk-lcloger.js正确方法和使用:
<script type="text/javascript" src="vk-lcloger.js"></script>

// 获取日志对象
let bugout = vk.getLogInstance('vk-a')
bugout.log('xxx')
bugout.log('000')
bugout.log(new Date())

let bugout2 = vk.getLogInstance('vk-b')
bugout2.log('vipkid log...');

// 显示日志面板
vk.VKConsole.getInstance().init()

// 获取日志
window.getLogModule('vk-a').getLog()
日志对象属性
  • realTime 实时输出到虚拟日志面板(默认false)
  • maxDepth 日志对象的最大递归深度(默认25,禁止循环引用)
  • autoTrim 为了避免日志占用潜在的无穷无尽的内存(默认true)
  • maxLines 如果autoTrim为真,那么最多将保存maxLines条日志(默认100)
日志对象方法
  • log()- 记录日志,同时console.log()
  • getLog() - 返回整个日志。
  • tail(numLines) - 返回日志的最后X行,其中X是您传递的数字。默认为100。
  • getSlice(start, numLines) - 获取日志的“切片”。通过起跑线和你想要的后面几行
  • clear() - 清除日志。