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

clever-logger

v1.0.10

Published

a logger can record request and respose data,it also can custom log,support output to console or local file

Downloads

3

Readme

clever-logger

a logger for nodejs's connect,express web framework,it can record request and response pivotal data,it also can custom log,support output to console or local file

Installation

npm install clever-logger

API

var logger=require('clever-logger'); var app=require('express')();

logger.init(jsonObjectparameter)

this function is necessary,before use this middleware,must first invoke it.this function with a json parameter,it is optional,if no definition,system would use default parameter

var defaultOptions={

level:'',//default:'all' ,optional values:'all','debug','info','warn','error','off'
//please take attention:dynamicLog normal log think it's log level is debug 
//all:record all log
//debug:record debug、info、warn、error log
//info:record info、warn、error log
//warn:record warn、error log
//error:record  error log
//off:not record any log
dynamicLog:{ //record request and response log setting

        isConsole:false,//whether show on console, default false
        immediate:false,//whether wait for request finish show or immediate show,default false
        successPath:'',//custom success log path,default logs/currentDate/success.log
        errorPath:'',//custom success log path,default logs/currentDate/error-dynamic.log
        logFields:['url','method','statusCode','responseTime'] //custom request and response field,
        //default 'url','method','statusCode','responseTime'
    },
staticLog:{ //custom log setting

        isConsole:false//whether show on console,default false
        infoPath:'',//custom logger.Info function log path
        debugPath:'',//custom logger.Debug function log path
        warnPath:'',//custom logger.Warn function log path
        errorPath:''//custom logger.Error function log path
    },
    format:'',//file or dir's name format,optional values:'yyyy-mm-dd' and 'yyyy-mm-dd hh'
    organizationType:1, //log file organization type,
    //optional values:1 and 2 such as 1:logs/2018-08-31/success.log 2:logs/2018-08-31_success.log

}

logger.init(defaultOptions);

you alse not use parameter such as:

logger.init();

app.use(logger(stringObjectParameter))

this is a middleware use,record requeset and response key data if you no set parameter,such as app.use(logger()), system will use default value ':url :method :statusCode :reponseTime' you also use part field such as app.use(logger(':url :statusCode'))

logger.info(data,function(err){});

if isConsole field value set true,the word color will be green

logger.debug(data,function(err){});

if isConsole field value set true,the word color will be blue

logger.warn(data,function(err){});

if isConsole field value set true,the word color will be yellow

logger.error(data,function(err){});

if isConsole field value set true,the word color will be red

Usage

Record Request and Response Log

var logger=require('clever-logger');
var express=require('express');
var app=express();

logger.init();

app.use(logger(':url :method :statusCode :responseTime'));
app.listen('3000');

Custom Log

var logger=require('clever-logger');
var express=require('express');
var app=express();


logger.init(
{

    level:'error',//only record error log,you can set other level,such as:'all','debug','info','warn','off'
    dynamicLog:{
            isConsole:true,
        },
    staticLog:{
            isConsole:true,
            errorPath:'error.log'
        },
        format:'yyyy-mm-dd hh',
        organizationType:2
});

logger.info('this is a info message',function(err){
    
});

logger.debug('this is a info message',function(err){
    
});

logger.warn('this is a info message',function(err){
    
});

logger.error('this is a info message',function(err){
    
});

Dependent Packages

Node Version

support node version>=0.8