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

logjs-mrh

v0.0.3

Published

A custom log management tool

Downloads

1

Readme

logjs-mrh

解决不能单独输出某个等级日志的问题产生的模块

快速使用

// 导入log包
const _log = require('./log');
// 创建log对象
/**
 * @param { String } name 别名
 * @param { Array } consoleOption 控制台输出的类型
 * @param { Boolean } toFile 是否输出到文件
 * @param { Object } toFileOption 输出到文件的配置
 */
const log = new _log('test', ["trace"], true, {
  trace: {
    path: "./trace.log"
  },
  info: {
    path: "./info.log"
  },
  debug: {
    path: "./debug.log"
  }
});

log.trace(1)
log.info(1,2)
log.debug(1,2,3)
log.addLevel('test', 'green', true, {});
log.test('test');

默认类别(level)

参考log4js

TRACE

使用方法 log.trace(msg)
控制台颜色 默认为蓝色blue

DEBUG

使用方法 log.trace(msg)
控制台颜色 默认为青色(蓝绿色)cyan

INFO

使用方法 log.info(msg)
控制台颜色 默认为绿色green

WARN

使用方法 log.warn(msg)
控制台颜色 默认为黄色yellow

ERROR

使用方法 log.error(msg)
控制台颜色 默认为红色red

FATAL

使用方法 log.fatal(msg)
控制台颜色 默认为品红色magenta

MARK

使用方法 log.mark(msg)
控制台颜色 默认为灰色grey

addLevel 使用方法

// 导入log包
const _log = require('./log');
// 创建log对象
const log = new _log('test', [], false);
// 添加test级别
/**
 * @param { String } level 级别名称 如果与默认类别重复为覆盖
 * @param { String } color 颜色(下一节为颜色的可选项)
 * @param { Boolean } isConsole 是否在控制台输出
 * @param { Object } toFileOption 输出文件配置
 */
log.addLevel('test', 'green', true, {});
// 使用级别
log.test(...msg);
// 特别注意 使用前一定要先定义
// 该方法也可用于覆盖

color的默认值

在控制台输出颜色 \x1b[31m输出信息\x1b[0m
其中\x1b[31m为开头31为颜色代码
颜色代码出处https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
颜色兼容请查看出处

|颜色名称|颜色对应程序代码|颜色代码| |-|-|-| |黑色|black| 30| |红色|red| 31| |绿色|green| 32| |黄色|yellow| 33| |蓝色|blue| 34| |品红|magenta| 35| |青色(蓝绿色)|cyan| 36| |白色|white| 37| |灰色|gray| 90| |鲜红色|bright Red| 91| |鲜绿色|bright Green| 92| |鲜黄色|bright Yellow| 93| |鲜蓝色|bright blue| 94| |亮品红色|bright Magenta| 95| |亮青色|bright Cyan| 96| |亮白色|bright White| 97|