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

@first-lego-league/ms-logger

v2.0.2

Published

Logger for FIRST Lego League System Modules

Downloads

38

Readme

npm codecov Build status GitHub

David Dependency Status David Dev Dependency Status David Peer Dependencies Status

FIRST Lego League Logger

A simple logger which works according to the FIRST LEGO League TMS Module Standard.

Usage

There are two ways to use the module: creating the logger directly ot using the middelware.

Create the logger directly

// import the logger
const { Logger } = require('@first-lego-league/ms-logger')

// Create a new instance
const logger = new Logger()

// Use the logger with the direct log method
// Passing to it the level and message
logger.log(logger.LOG_LEVELS.DEBUG, 'some message')
// Or use the level method directly
logger.debug('some message')

Available levels are: DEBUG, INFO, WARN, ERROR, FATAL

When you try to write a log, the logger only logs it if the message's level is higher then the log's logLevel. You can access the logLevel proeperty like this:

const { Logger } = require('@first-lego-league/ms-logger')

const logger = new Logger()
logger.logLevel = logger.LOG_LEVELS.WARN
console.log(logger.logLevel) // 2

Use the node middleware

const { loggerMiddleware } = require('@first-lego-league/ms-logger')
const app = require('express')()

app.use(loggerMiddleware)

This adds a double functionality:

  1. Each HTTP request to pass through this middleware will be logged, together with its method, URL, the time it took, its issuer and its status code.
  2. You can now request from the server to log using HTTP POST to the /log/:level endpoint: POST http://server/log/debug message="some message". The server responds with a 201 on success and a 500 on failure.

Contribution

To contribute to this repository, simply create a PR and set one of the Code Owners to be a reviewer. Please notice the linting and UT, because they block merge. Keep the package lightweight and easy to use. Thank you for contributing!