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

npmlogger

v1.6.0

Published

Write your logs natively from npmlog with minor change in your application

Downloads

437

Readme

npmlogger

Build Status Dependency Status Donate

NPM Logger is a package designed to write easily your log files. For more convenience npmlogger extends npmlog, so you can use it with minor changes in your application code.

Installation

npm install npmlogger --save

Basic Usage

// Call npmlogger instead of npmlog
var log = require('npmlogger');

// Set the log level required to be written
log.fileLevel = 'warn';

// Set the basepath for log files
log.fileBasePath = './logs';

// Set the filename
log.fileName = 'mylog.log';

// write error log to mylog.log
log.info('My prefix', 'i am info'); // Displayed but not written
log.error('My prefix', 'i am error'); // Displayed and written

Output :

[Fri Feb 03 2017 18:14:44 GMT+0100 (CET)] [error] [My prefix] i am error

Configuration

Note: All npmlogger methods and variables start with file.

log.fileName

  • {String}

The file name, .log extension is automaticly added at the end of name.

log.fileBasePath

  • {String}

The base path for the logs file, by default this is the logs directory related to the executed file.

log.fileCreatePath

  • {Bool}

When this feature is enabled, the path is automaticly created. Use mkpath package.

log.fileLevel

  • {String}

The level to write logs. Any logs at or above this level will be written. The special level silent will prevent anything from being logged ever.

log.fileColor

  • {Bool}

By default npmlogger remove all console colors from file. You can allow colors by setting this option to true.

log.fileMaxSize

  • {Number}

Set the max size for the log file, when the limit is reached the file is moved and a new one is created. The size is exprimed in kilobyte. The new file is named mylog_1.log or mylog_error_1.log if you enable log.fileLevelSuffix.

log.fileDatePrefix

This option allow you to prefix the filename with your own date format.

Note: The date prefix is always put before log.fileHeadPrefix.

log.fileHeadPrefix

  • {Bool}

This option allow you to prefix the files with the log.heading value like heading_mylog.log.

Important It is highly recommended to use slug keyword for log.heading or enable log.fileSlugify when log.fileHeadPrefix is enabled.

log.fileLevelSuffix

  • {Bool}

This option create seperated log file for each log level. So you can have mylog_error.log, mylog_warn.log, mylog_info.log etc...

Important It is highly recommended to use slug keyword for custom level or enable log.fileSlugify when log.fileLevelSuffix is enabled.

log.fileSlugify

  • {Bool}

When this feature is enabled the filename is slugified using RCF3986 standard.

log.fileEntriesTemplate

  • {Bool}

When disabled this option remove the current default template and let you decide how to manage your entries.

Note: The template is [date] [level] [prefixes] error, when disabled you only have prefix error.

Bug & suggestions

If you have any suggestions or found a bug feel free to use the tracker.