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

log-client-node

v0.0.2

Published

Log API for Nodejs {#welcome} =====================

Readme

Log API for Nodejs {#welcome}

log API for nodejs for new house projects based on nodejs is used for generate logs which more friendly to Centrailzed Logging System[^cls]

log API for nodejs is based on tracer

svn repository

https://xmsvn.ehealthinsurance.com/svn/centralized-logging/branches/dev/log-client-node


What logs printed by log-client-node looks like

####pattern

level:{{title}}|$|timestamp:{{timestamp}}|$|requestId:{{requestId}}|$|class:{{file}}|$|line:{{line}}|$|message:{{message}}

####example

level:info|$|timestamp:2014091617010569|$|requestId:|$|class:index.js|$|line:12|$|message:hello world!

How to use it

add dependency to package.json

"dependencies": {
    "log-client-node":                      "0.0.2",
}

install log-client-node

npm install

require log-client-node in your code

app.log = require('log-client-node')(setting);

Here is the setting example

setting = {};
setting.APP_NAME = 'xis';
setting.logDirectory = 'logs';
setting.strategy = 'console'; // [console, colorConsole, dailyfile]
setting.level = 'info';

temp log file

log API for nodejs will create a temp log file beside the original log file. For example: If the original log file named "2014-09-10-xis-node.log" then there will be a log file named "2014-09-10-xis.log.temp" be created.


Usage

Log file name

log-client-node will create log file which name is in this format logDate + "-" + appName + "-node.log".

for example 2014-06-08-xis-node.log

Print 4 levels logs

log-client-node support 4 levels logs like log4j: debug, info, warn, error

####example

logger.log('hello');
logger.trace('hello', 'world');
logger.debug('hello %s',  'world', 123);
logger.info('hello %s %d',  'world', 123, {foo:'bar'});
logger.warn('hello %s %d %j', 'world', 123, {foo:'bar'});
logger.error('hello %s %d %j', 'world', 123, {foo:'bar'}, [1, 2, 3, 4], Object);

Log Transaction

log-client-node supports log transaction. It can helps you to print the duration time of one operation, such as database IO, read file, send request, etc.

####Usage

  1. Use log.newTransaction(transactionContext) to create a log transaction. transactionContext can be a String or a JSON Object.
  2. Use log.completeTransaction() at the end of this operation. Then it will print a log with your transactionContext and the duration time.

NOTE:

####example

    app.log.info('Begin to query code table, sql: select * from code_product_type ');
    app.log.newTransaction('sql: select * from code_product_type');
    var mysql      = require('mysql');
    var connection = mysql.createConnection({
        host     : '192.168.1.33',
        port     : 3306,
        user     : 'admin',
        password : 'lkjhgf',
        database : 'test'
    });
    connection.connect();
    connection.query('select * from code_product_type', function(err, rows, fields) {
        if (err) throw err;
        app.log.completeTransaction();
        res.send({ 'hello': 'world1' });
    });
    connection.end();
    

####Result

level:info|$|timestamp:2014091716555489|$|requestId:|$|class:D:\WebstormProjects\log-client-node-demo\index.js|$|line:15|$|message:hello log-api
level:info|$|timestamp:2014091716555490|$|requestId:|$|class:D:\WebstormProjects\log-client-node-demo\index.js|$|line:17|$|message:Begin to query code table, sql: select * from code_prod
uct_type
level:info|$|timestamp:2014091716555575|$|requestId:|$|class:D:\WebstormProjects\log-client-node\index.js|$|line:122|$|message:{transContext:"sql: select * from code_product_type",durati
on:847}

[^cls]: Centralized Logging System is a log collect system. You can query all logs generated by ehi project, whatever new house or old house. Engineers can use this system to do troubleshooting.