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

logger-ro

v1.0.1

Published

easy logger for nodejs server

Readme

logger-ro

用来打印调试日志的模块. 日志可以设置不同的级别,可以扩展的打印输出,可以选择打印时是否使用颜色选项.

user guide

install

npm install logger-ro

use

最简单使用方式

var Logger = require('logger-romens');
var logger = new Logger();

logger.trace('myKey', 'myValue');
// 输出如下:
// [TRACE][2016-09-21 15:04:10.956][/test/test.js:69][null] [myKey:myValue]

我们可以省略key

logger.trace('myValue');
// [TRACE][2016-09-21 15:04:10.956][/test/test.js:69][null] [-:myValue]

其他调用方法:

logger.sql('mySQL');
logger.sqlError(errorObject);
logger.debug('myKey', 'myValue');
logger.info('myKey', 'myValue');
logger.warn('myKey', 'myValue');
logger.error(errorObject);
logger.fatal('myKey', 'myValue');
logger.errorWithStack(errorObject);

以上所有的key都可以省略

OPTION

logger类接收option以控制不同的行为


var logLevel = "TRACE";
var printer = function (msg) {
  var prefix = 'development logger: ';
  console.log(prefix + msg);
};

var option = {
  level: logLevel,
  printer: printer,
  isColorful: false
};

var logger = new Logger(option);

logger.trace('myKey', 'myValue');
// 输出如下:
// development logger: [TRACE][2016-09-21 15:04:10.956][/test/test.js:69][null] [myKey:myValue]
  • level

其中level用于控制logger打印的等级, 等级分布如下:

| 等级 | 级别 | 方法 | | --- | --- | --- | | TRACE | 0 | trace | | TRACE | 0 | sql | | DEBUG | 1 | debug | | INFO | 2 | info | | WARN | 3 | warn | | ERROR | 4 | error | | ERROR | 4 | sqlError | | ERROR | 4 | errorWithStack | | FATAL | 5 | fatal |

当设置一个级别后,低于此级别的日志不会打印出来

  • printer

用与改变日志输出,可以地定义日志的输出方式

  • isColorful

用与设置打印日志是否使用色彩(色彩仅在shell中有效)