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

ollyutils

v1.0.1

Published

A simple package for logging and managing basic environment variables

Readme

OLLYUTILS v0.1

PLEASE NOTE THIS IS STILL IN DEVELOPMENT

A simple package for logging and managing environment variables.

The package consists of 2 utilities:

1. Environment config

Overview

Environment config allows you to maintain a set of environment config within your own project using a 'config.json' file at the root of your project directory.

Basic use

In order to use Environment config you will need to have a base level file in your project called 'config.json'. This file will need to be a basic json file with an element for each environment you intend to use. For example:

{
    "dev": {
        "name" : "development",
        "port" : 1234
    },

    "prod": {
        "name" : "production",
        "port" : 8080
    }
}

When you want to use an environment variable in your code you will need to require the utils package:

var utils = require('ollyutils')

and then create reference your config as follows:

var config = utils.config

The value of the environment you are using is set as an npm environment variable called 'environment'. You will need to set this before running your script as follows:

npm config set environment dev

This will set the environment as 'dev' and correspond to the 'dev' object in your config.json file.

If no environment variable is set the default value will be 'dev'. If no element in your config.json file corresponds to your environment variable you will receive an undefined object and an error will be logged.

2. Logging

Overview

Logging is a simple framework for logging some basic information to aid with support, debugging and monitoring. It logs in the following format:

[timestamp] | [calling file] | log text

For example:

07/03/2018 09:13:04:222 | index.js | "Service initiated"

Basic Use

First you will need to require ollyutils:

var utils = require('ollyutils')

Then you can define your log constant:

var log = utils.log;

The log function is then called using 2 parameters.

  1. The level of logging A number from 1-5 where 1 = Info and 5 = Silly on the logging scale. Your log level must be set as an environment variable called 'LOG_LEVEL'. If this parameter doesn't exist it will default to '1'

    You can set this value using the command:

     npm config set LOG_LEVEL 3

    Where '3' is the level of logging you want to set

    In reality this number can be greater than 5 or less than 1 if you wish to have more logging levels.

  2. Your log text This can be either plain text or JSON, which will be stringified.

    For example you would log at silly level by calling:

     log(5 , 'This is some arbitrary information')

    and provided the log level is greater than or equal to 5 the following would be outputted:

     07/03/2018 09:13:04:222 | index.js | "This is some arbitrary information"

An example

The following would use the environment variable passed as a parameter (this could also be set in a separate file) to start a basic express endpoint on a specified port:

index.js:

//Create the utils objects
var utils = require('ollyutils')
var config = utils.environment(process.argv[2]);
var env = config.ENVIRONMENT;
var log = utils.log

//Require express
var express = require('express');
var app = express();

app.get('/', function (req, res) {
	res.status(200).send('Look Mum! I dun it!')
})

var port = config.PORT
app.listen(port);
log(1,'Listening on port ' + port);

Command:

node index.js dev

Output:

07/03/2018 09:47:14:143 | index.js | "Listening on port 12345"