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

log4slow

v0.1.1

Published

log to file or console, support .log or .html

Downloads

67

Readme

Install

  npm install log4slow

Using

  Log = require("log4slow")
  
  Log.info("hello, this is infomation")
  Log.warn("hello, this is warning")
  Log.error("hello, this is error")
  Log.debug("hello, this is debug")
  
  //and can accept  Object or Error
  Log.info({a: 1, b: 2})
  Log.warn([1, 23, 4, 5])
  Log.debug(new Error('test log'))
  

test

  cd log4slow
  npm test

example

 cd log4slow/example

configure

In the default, read the configure appRoot/log4slow.json, if it isn't exists, will use log4slow's default configure

{
  /*
  * Do output to console ?  Boolean or Object    
  * Default: true
  * if show all set 'log2console: true',  otherwise, set 'log2console: false'
  * if just need some of them ,set the type true. 
  * for example just output debug:   
  *     log2console: {debug: true}
  */
  "log2console": true; 

  /*
  * Do output timestamp ? Boolean or String.  
  * Default: "YYYY-MM-DD HH:mm:ss"
  * if show this, set date foramt string. for example: "YYYYMMDD".  
  * the format rule please see http://momentjs.com/docs
  * otherwish, set timestamp: false
  */
  "timestamp": "YYYY-MM-DD HH:mm:ss",

  /*
  * Do output log level ?   Boolean    
  * Default: true
  * if true, will output "[DEBUG]|[INFO]|[ERROR]|[WARN]" in console for log
  * if don't need this , set it be false
  */
  "levelShow": true,

  /*
  * Do output the file name and line number ?  Boolean or Object. 
  * Default: {error: true, debug: true}
  * if output all type, set "lineInfo": true . otherwise set  set "lineInfo": false
  * if just output for some log level,  set the level be true. 
  * e.g :   lineInfo:{"error": true, "debug": true}
  *
  * Note !!!!!
  *    Output the file name and line number  will consume a lot of system resourse . 
  * Suggestion:
  *    In the develop enviroment , you can set it as you want. 
  *    In the product enviroment, set lineInfo just for error level log.  
  *       for example: lineInfo: {"error": true}
  */
  "lineInfo": {
    "error": true,
    "debug": true,
  }, 

  /*
  * Do output to file ?   Boolean or Object.  
  * Default:  false
  * the rule like  log2cosole
  */
  "log2file":{
      "debug": false,
      "info": true,
      "warn": true,
      "error": true
   },

   /*
   * set the directory for log file.   directory path (absolute path) or  Boolean.   
   * Default: false
   * if false  the log file will be save in app root. 
   * or the path  like  "C:\\logs\\"    "/home/username/logs/"
   */
   "dirRoot": false,

   /*
   * Where is log file ?   Array  or Bealean .  
   * Default: false.
   * Note:  it's effective only the log2file be allow
   *
   * log file be save to [app-root|absolute path]/logs  if dirs is false
   * dirs access a Array,  for example like this: ['a', 'd' ], 
   * so the file will be save to  [app-root|absolute path]/a/d
   *
   * it will be format to time if  begin with '$'.
   *    the format rule please the http://momentjs.com/docs
   *
   * it will be format log type if begin with ':'
   * the following option will be format :  
   *    [app-root|absolute path]/logs/2014/07/[error|warn|debug|info]
   */
   "dirs": ["logs", "$YYYY", "$MM", ":type"], 

   /*
   * what is name the file ?  String   
   * Default: $YYYMMDD
   * it will be format to time if begin with '$'
   * the following option will be format 20140725
   */
   "filename":"$YYYYMMDD",

   /*
   * Do separately save log file accord log type ?  Boolean or Object .
   * Default: false
   * if error is true:
   *    the log file will be   [app-root|absolute path]/[dirs]/error
   */
   "levelfile": {
      "error": true,
      "info": true,
      "warn": true,
      "error": true
   }
}

API

warn, info, error, debug

Accept JSON Object, Error Object , and string,number ...

init

Accept JSON Object as configure. will replace default configure's property

Log.init(configObject)