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 🙏

© 2026 – Pkg Stats / Ryan Hefner

swaler

v1.0.6

Published

A Simple Web App Logger designed for... web apps!

Readme

Swaler

build Publish to NPM

Swaler makes you easy and simple to log message in your web app, but not only that!

It has been developed on top of javascript console and support the following methods: .trace, .debug, .info, .warn, .error

Installation

npm install swaler

Usage

import {Logger} from 'swaler';

// A simple logger
const logger = new Logger();

logger.debug('Hello there!'); // Hello there!

// A logger with a Context
const loggerWithCtx = new Logger('Dalaran');

loggerWithCtx.debug('A new expansion has been detected...');
loggerWithCtx.info(`Time to go to Northrend.`);
loggerWithCtx.warn('Attention', 'to', 'take off!');
loggerWithCtx.error('A %s has been found!', 'crater');

// [Dalaran] A new expansion has been detected...
// [Dalaran] Time to go to Northrend.
// [Dalaran] Attention to take off!
// [Dalaran] A crater has been found!

Create a logger

// Several ways to create a logger
const logger = new Logger();
const logger = new Logger(context);
const logger = new Logger(null, opts);
const logger = new Logger(context, opts);

context

type: string

default: null

Give the logger a specific context that will be prompt between brackets

Very useful when, for examples, you want to log messages in some of your components without having to specify the component name each time you log something!

// Example using Context

import {Swaler} from 'swaler';

class AuthService {
  constructor() {
    this.logger = new Swaler('AuthService');
  }

  signIn() {
    // ... your awesome sign in implementation ...

    this.logger.info('User has successfully signed in!');
    // ... or maybe ...
    this.logger.error('An error occurred when trying to sign in user');
  }
}

// [AuthService] User has successfully signed in!
// [AuthService] An error occurred when trying to sign in user!

opts.level

type: SwalerLevel

default: null

Set the minimal level of log to display

import {Swaler, SwalerLevels} from 'swaler';

const logger = new Swaler(null, {level: SwalerLevels.WARN});

logger.debug("Won't be logged!");
logger.info("Won't be logged!");
logger.warn('Will be logged!');
logger.error('Will be logged!');

Log

All log methods are built on top of console which means that each Swaler log methods act the same way than console methods!

logger.trace

Display a trace log

logger.trace('A trace message');

logger.debug

Display a debug message

logger.debug('A debug message');

logger.info

Display an info message

logger.info('A info message');

logger.warn

Display a warn message

logger.warn('A warn message');

logger.error

Display a error message

logger.error('An error message');

Log with options

Sometimes, you may need to pass options when calling a log. To do so, use withLogOptions() methods

logger
  .withLogOptions({
    ignoreLevel: boolean,
  })
  .info('An info message with options');

Available options

| options | Type | Description | | ----------- | ------- | --------------------------------------------- | | ignoreLevel | boolean | Make the log ignoring the level of the logger |

SwalerLogOptions.ignoreLevel

const logger = new Logger('AuthModule', {level: SwalerLevels.WARN});

logger
  .withLogOptions({ignoreLevel: true})
  .info('Will be logged despite the WARN levels!');

Misc

Swaler.defaultLevel

type: SwalerLevels

default: SwalerLevels.DEBUG

By default, all loggers will use the defaultLevel if you do not pass a opts.level.

import {Swaler, SwalerLevels} from 'swaler';

Swaler.defaultLevel =
  process.env.NODE_ENV === 'production'
    ? SwalerLevels.WARN
    : SwalerLevels.DEBUG;

const logger = new Swaler();
const loggerWithLevel = new Swaler(null, {level: SwalerLevels.INFO});

logger.info("Won't be logged");
loggerWithLevel.info('Will be logged');

Why are you using process.env here ?

Check this article on how to manage front-end js env variable

Contributing

You are welcome to contribute, see Contributing.

License

MIT