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

raven-logger

v0.3.2

Published

Logging messages to stdout/stderr as well as reporting to Sentry in one command.

Downloads

27

Readme

raven-logger

Logging messages to stdout/stderr as well as reporting to Sentry in one command.

Usage

const Logger = require('raven-logger')
const sentry = require('@sentry/node')

sentry.init({ dsn: 'https://<key>@sentry.io/<project>' })

const logger = new Logger({ sentry })

async function main() {
  try {
    const data = require('fs').readFileSync('foo.txt')
  } catch (e) {
    // You can provide the timestamp and eventId to the user,
    // so he/she can give feedback with these information to help locating the issue.
    const { timestamp, eventId } = logger.error(e)
  }
}

main()

Constructor

new Logger({ sentry, timezone, logLevel = 'debug', reportLevel: 'info', debugTrace = true })

Arguments:

sentry: Object, the sentry module. Optional. If not provided, logs won't be send to sentry.

timezone: String | Boolean. Optional. Timezone of timestamp. Defaults to true.

logLevel: Optional. What level of logs should output to stdout or stderr. Enabling logging at a given level also enables logging at all higher levels.
Levels from high to low: critical, fatal, error, warning, info, log, debug.
Defaults to debug.

reportLevel: Optional. What level of logs should report to sentry server. Enabling reporting at a given level alsa enables reporting at all higher levels.
Defaults to info.

debugTrace: Boolean. Optional. Whether to log trace at debug level. Defaults to true.

You can change the settings through theses properties after initialization:

logger.sentry
logger.timezone
logger.logLevel
logger.reportLevel
logger.debugTrace

Logging methods

  • logger.debug(...messages)
  • logger.log(...messages)
  • logger.info(...messages)
  • logger.warn(...messages)
  • logger.error(...messages)
  • logger.fatal(...messages)
  • logger.critical(...messages)

Arguments:

...message: Any type. Final output string will be util.format(...messages), same as console.log(...messages).

Returns:

{ timestamp, eventId }

The logging format is [timestamp][eventId][logLevel] messages.

timestamp: String. The timestamp prepending the log message, in ISO 8601 format. If the log level is disabled logging, nothing will be logged, so timestamp and eventId will be empty string.

eventId: String. The evend ID prepending the log message. If sentry is set, the value is generated by sentry. Else it is generated from random bytes. If the log level is disabled reporting, eventId will be empty string.

LICENSE

MIT