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

logdog

v1.0.1

Published

A tool for logging and debugging important events in your app that a developer should be able to easily be notified about and look into.

Downloads

3

Readme

Logdog

A simple module for logging and alerting about spesific critical events inside your app for further inspection by a developer.

Writes log messages to std.out or std.err.

Supports notifying a Slack channel (fully optional).

Disclaimer

Logdog is not meant to be your application logger or debugger! It's a tool for logging spesific events in your app, and let someone know about it (it may not even be a developer). Logdog's barks let you know something is wrong without looking at exceptions, stacktraces and stuff like that. It's a call to actions for further debugging / log file inspection by a developer.

Usage

Install

npm install logdog

Initialization and configuration

Logdog is first initialized in your app by requiring it and passing configuration options for it:

  var logDog = require('logdog')(...config);

Next time you require it, you will get the singleton instance of the first require, so you don't need to configure Logdog all over the place.

Another place in the code (call without any options):

var logDog = require('logdog')();

Logdog is now configured with options from the first initial require statement.

Log something

  logDog('myApp.myFeature').bark('Winter is coming!');

The function parameter to logDog is the prefix for the log line, indicating where in the application/script the event occurred.

Then we call .bark(message) to assign the actual log message.

If we want, we may put it on Slack too:

  logDog('myApp.myFeature').bark('Winter is coming!').toSlack({notify: '@jon'});

Configuration options

  • prefix String to prefix any log messages with. Default is logdog.

  • bindTo By default Logdog.bark goes to sdt.err. Value stdout will bind it to std.out. Value null will disable any output (i.e. for only sending to slack).

  • slack

    The slack property is a hash of the following keys:

    • url: Required. I.e. 'https://hooks.slack.com/services/XXX/YYY/abc'
    • channel: Required. I.e. '#appNotifications'
    • username: Optional. Defaults to 'LogDog'.
    • emoji: Optional. An emoticon associated with the message. Defaults to ':dog:',
    • notify: Optional. Slack username(s) to notify. I.e. '@jon' or ['@jon', '@samwell'].

Examples:

Simple log to std.err

  var logDog = require('logdog')();
  logDog('myapp.myfeature').bark("Something went so wrong!");

Simple log to std.out

  var logDog = require('logdog')({bindToStdOut: true});
  logDog('myapp.myfeature').bark("Did something of importance!");

Log and send to Slack

  var logDog = require('logdog')({
    slack: {
      url: 'https://hooks.slack.com/services/XXX/YYY/abc',
      channel: '#appNotifications'
    }
  });

  logDog('myapp.myfeature')
    .bark("Did something of importance!")
    .toSlack()

Log, send to Slack and override previously configured Slack options:

  logDog('myapp.myfeature')
    .bark("Something went horribly wrong!")
    .toSlack({emoji: ':heavy_exclamation_mark:', notify: '@myusername'})