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

@appku/stashku-log

v0.3.3

Published

A StashKu middleware for outputing log messages to console or to a flat file.

Downloads

66

Readme

NPM License Downloads

StashKu Log Middleware

This StashKu middleware project provides logging to console and/or to a rolling file directory. It provides support for the various severities of StashKu logging: error, warn, info, and debug.

StashKu Log can also be used independently, without StashKu to simply log in a standardized way that enforces severity level logging (no console.log generalities).

This package supports 2 modes of logging, each can be enabled/disabled and configured independently of one another:

  • "console": Outputs logs to stdout (usually to the terminal). This logger is enabled by default.
  • "file": Writes logs to a log file on a file-system. Currently under development.

Getting Started

npm i --save @appku/stashku-log

To utilize this middleware with stashku, this middleware can be passed to StashKu through the configuration to provide functionality.

import log from '@appku/stashku-log';
let stash = new StashKu({
    middleware: [log],
    '@appku/stashku-log': {
        console: {
            enabled: true,
            severity: 'info',
            colors: true,
            timestamp: true,
            local: true
        },
        file: {
            enabled: false
            path: './'
        }
    }
});

Code Quick-Start

You should utilize your StashKu instance's log property to make logs function calls. In the absence of StashKu, you can make log calls directly with this library:

Within StashKu

let stash = new StashKu( ... ); ///see Configuration section below
stash.log.debug('Look ma! I am debugging.');
stash.log.info('Look ma! I am pretty.');
stash.log.warn('Look ma! I am smoking.');
stash.log.error('Look ma! I am on fire.');

Without StashKu

import log from '@appku/stashku-log';
log.debug('Look ma! I am debugging.');
log.info('Look ma! I am pretty.');
log.warn('Look ma! I am smoking.');
log.error('Look ma! I am on fire.');

Loading After StashKu Initialization

Alternatively, if not loaded by configuration of the StashKu middleware property (as shown above), you can use StashKu's use middleware function:

import log from '@appku/stashku-log';
myStashKuInst.use(log);
...

Without StashKu

If you are using the stashku-log without StashKu, you can still configure the module, as shown below:

import log from '@appku/stashku-log';
//set the configuration object on the module directly
log.config = { 
    console: { ... }, 
    file: { ... }
}
...

To configure the library without StashKu, set the config property on the module or use environmental variables.

Documentation

Formal documentation is available here.

Available Configuration Properties

| Property | ENV | Type | Default | |-|-|-|-| | console | | Object | | | ↳ console.enabled | STASHKU_LOG_CONSOLE_ENABLED | Boolean | true | | ↳ console.severity | STASHKU_LOG_CONSOLE_SEVERITY | String | | | ↳ console.timestamp | STASHKU_LOG_CONSOLE_TIMESTAMP | Boolean | true | | ↳ console.local | STASHKU_LOG_CONSOLE_LOCAL | Boolean | true | | ↳ console.colors | STASHKU_LOG_CONSOLE_COLORS | Boolean | true | | file | | Object | | | ↳ file.enabled | STASHKU_LOG_FILE_ENABLED | Boolean | false |

You can utilize environmental variables or define the values through a configuration object passed to StashKu. This project also loads .env files in it's package directory.

Running

Run npm start

Building

This project uses node.js to run and does not have an explicit build process.

Code Documentation

You can generate a static JSDoc site under the docs/ path using the command npm run docs.

Testing

This project uses jest to perform unit tests.

Running Tests

Run npm test to run jest unit tests.

Run npm run lint to run ESLint, optionally install the Visual Studio Code ESLint extension to have linting issues show in your "Problems" tab and be highlighted.

If you are writing unit tests, you may need to npm install @types/jest to get intellisense in Visual Studio Code if for some reason it did not get installed.

Publishing

Only maintainers with proper access can publish this package to npm. To do so as maintainers, you can publish by running the following command:

npm publish --registry=https://registry.npmjs.org --access=public