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

@orphaneater/frill-free-logger

v1.0.6

Published

Basic dependency free logging to files and console

Downloads

1

Readme

frill-free-logger

If you're looking for the best logging mechanism created for nodejs, you should probably keep looking because this ain't it.

Do you want your log messages to look like this?

[INFO]    2020:08:05 18:41:40 HTTPRequests - what a woild
  {
    "data": "this would be some important data, or not, I'm not the data police"
  }
[WARNING] 2020:08:05 18:41:40 HTTPRequests - what a woild
[ERROR]   2020:08:05 18:41:40 HTTPRequests - what a woild

Then here's how to use this thing:

This very basic logger is constructed with a settings object, or not:

const logSettings = {
  name: "HTTPRequests",
  fileName: "./httpRequests.log",
  stdout: false
}

Using the logger works like this:

let FFL = require('@orphaneater/frill-free-logger')
const logSettings = { // .. see above }
httpLog = new FFL(logSettings)

httpLog.info(`Making request to ${someUrl}`)

makeARequest(someUrl).then((jsonBody) => {
  httpLog.info(`Received HTTP response from ${someUrl}`, jsonBody)
  if (jsonBody.accountBalance < -20.00') {
    httpLog.warning(`Does the ${jsonBody.accountBalance} include the money you owe me?`)
  }
}).catch((err) => {
  httpLog.error(`Damn. ${someUrl} responded with an error`, err)
})

And would output similar to this if each scenario were hit:

[INFO]    2020:08:05 18:40:40 HTTPRequests - Making request to https://example.com
[INFO]    2020:08:05 18:40:42 HTTPRequests - Received HTTP response from https://example.com
  {
    "accountBalance": -31,
    "deadBeat": true
  }
[WARNING] 2020:08:05 18:40:43 HTTPRequests - Does the -31 include the money you owe me?
[ERROR]   2020:08:05 18:40:46 HTTPRequests - Damn. https://example.com responded with an error
  {
    "type": "Failure",
    "msg": "An error has occurred",
    "helpful": false
  }

Install

npm install @orphaneater/frill-free-logger

Settings

name: Added to your log messages. You can use it, or not. Ideal for cases where you might want multiple loggers. When it's not added, it's simply omitted from the logs.

fileName: Full path to the filename you want to write a log to. This doesn't do anything fancy like create the path to the file if it doesn't already exist. In fact, it's so low brow that if this is defined and the path isn't valid it will throw an exception. If it's not set, no file gets written.

stdout: Determines whether or not to print the log messages to the terminal. Defaults to true.

Dependencies

Nope.

Testing

Right. Because your use of a module someone else wrote hinges on whether or not the tests, they also wrote, pass.

Contributing

  • Click here
  • Copy the entire contents of this file and paste it into an editor of your choice.
  • Make whatever changes you would like.
  • Push it to your own repository.
  • Publish your own module.