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

@uandev/log

v3.0.0

Published

My custom logging solution for all of my apps.

Downloads

1

Readme

UANDEV - Log Module

My custom logging solution for all of my apps.

Usage

This module works best with Typescript. It provides three items:

Level

An enum detailing the various available log levels

LogWriter

An interface describing the available functions for writing events. It contains the following functions: trace, debug, info, warn, error, and fatal. They all have the same signature: (message: string, data: any)

GetWriter

A function with the signature: (namespace: string) => LogWriter that returns a LogWriter object for writing events for the provided namespace.

Setup

A function with the signature: (settings: ISettings) => void. It allows you to make changes to the Log module during runtime.

ISettings

An interface for modifying the settings of the Log module. It contains the following options:

appName

The name of the application as it should appear in the log. It will also be used ast the base of the namespace for events. Default: 'defaultApp'

level

The level minimum level of log output. Use the enum Level to set this. Default: info

color

Output colored log events. Very helpful for viewing during development. Not recommended for production when events are sent to a file. Default: false

timestampFormat

The format you would like to use for event timestamps. This is just a pass through directly to the moment time formatter. Default: 'YYYY-MM-DD HH:mm:ss'

enabled

Enable or disable log events. Default: true

output

A function to use for output of events. This function should have the signature: (output: string) => void. If you want to completely disable output, you can also pass null. This is mostly useful for the unit tests. Default: console.error

cluster

A boolean that signals whether or not to add cluster information to the namespace. When enabled events generated by master will be like this: myapp:master:some:name:space. Worker processes will generate events like this: myapp:worker:1:some:name:space.

Example

import { Log } from '@uandev/log'
Log.Setup({
  color: true,
  output: console.log,
  level: Log.Level.warn,
  appName: 'myapp'
})

let w = Log.GetWriter('test')

w.warn('This will output', { sample: 1 })
w.info('This will not be output')

The output will look like this:

2019-07-04 12:48:32 thehost myapp[9828]: warn myapp:test [sample='1'] This will output