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

arc-log

v1.0.12

Published

A full featured logging solution for Node.js

Downloads

4

Readme

arc-log

arc-log is a full featured logging solution for Node applications. arc-log handles log messages to the console and a log file on the filesystem.

Install

npm install --save arc-log

Use

First require arc-log:

var arc = require('arc-log');
var log = arc.log;

Next, drop console from console.log statements and add a log level:

console.log("foobar");

// Becomes...

log("foobar", "log_level");

Different log levels will print the message using different colors. See default option in the configuration section for colors.

You can require log directly if you are okay with default settings:

var log = require('arc-log').log;

Additionally, it is recommended that you use the error function for all error reporting. This will include the full error and the stack trace whereas the log function does not. You can use the error function like this:

var arclog = require('arc-log');

arclog.error("This is a message you want to show in front of the error", errorObject);

Configuration

Several configuration options are exposed including:

  • max_log_level - This is the numerical representation of the highest log level you want to show in logs. For example, if you only wanted errors to show in logs, set this to 1. If you want everything to show, set this to 5. Default value is 5.
  • log_to_file - True/False - do you want stuff logged to a file also? Default value is false.
  • path - The location of the file you want to log to on your filesystem. This is only needed if log_to_file is true. Setting does not exist by default.
  • log_to_console - True/False - do you want messages to print to the console? Default value is true.
  • timestamp_format - The format for timestamps. arc-log uses moment so reference the documentation here. Default value "M/D/YYY HH:mm:ss:SSS".

These can be accessed using the set() function:

arc.set(key, value);

// For example
arc.set(max_log_level, 1);

You can edit log levels and colors directly in arc.js. Log levels are mapped to numerical levels with level_map:

// Default options
var level_map = {
  "ERROR": 1,
  "FATAL": 2,
  "WARN": 3,
  "INFO": 4,
  "DEBUG": 5
};

You can also edit colors:

// Default options
var level_colors = {
  "ERROR": colors.red,
  "FATAL": colors.magenta,
  "WARN": colors.yellow,
  "INFO": colors.cyan,
  "DEBUG": colors.blue
};