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

fe-logs

v1.0.13

Published

利用nodejs编写的前端本地日志打点系统

Downloads

31

Readme

介绍

利用nodejs编写的前端本地日志打点系统

安装

npm i fe-logs -S

使用

const log = require('fe-logs');
log.info('this is a log');

设置日志文件名称

log.setName('.myLog.log');

如果需要按日期分类日志,可动态设置日志文件名称,比如:

log.setName(new Date().toLocaleString().split(' ')[0] + '.log');

模式

不同的模式会利用不同的console方法,详情见以下表格:

模式 | 对象的方法 -|- 空 | 需手动调用log.info() log | 日志为所有console.log方法输出的内容 info | 日志为所有console.info方法输出的内容 warn | 日志为所有console.warn方法输出的内容 error | 日志为所有console.error方法输出的内容

比如模式为error时,则除了log.info输出的内容外,代码中的所有console.error信息也都会导出到日志文件。例如:

const log = require('fe-logs');
log.setMode('error');

可以同时设置多种模式。例如:

const log = require('fe-logs');
log.setMode('log');
log.setMode('info');
log.setMode('warn');
log.setMode('error');

如果没执行log.setMode()方法或者模式为空或者表格之外的mode,则不会自动输出日志,需要在输出日志的地方手动调用log.info。例如:

const log = require('fe-logs');
log.info('this is a log');

帮助

  1. 日志文件叫什么名称?

    • 默认叫.myLog.log
    • 可以通过log.setName设置
  2. 日志文件在哪?

    • windows:
      1. 打开C盘,然后进入Users(用户)文件夹
      2. 进入登录用户的文件夹,比如xudeming
      3. 找到.myLog.log
    • mac:
      1. 右键点击Finder(访达),点击“前往文件夹”
      2. 输入框中输入/,点击前往按钮即可打开根目录
      3. 点击用户文件夹,然后点击登录用户的文件夹,比如xudeming
      4. 如果没有显示隐藏文件夹,可以按下快捷键command + shift + .显示隐藏文件
      5. 找到.myLog.log
    • linux:
      1. 执行命令cd ~
      2. 找到.myLog.log
  3. 如果要输出trace,可以在参考如下:

    console.error(JSON.stringify({
    	trace: console.trace()
    }));