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

@shiraya-ma/mai-logger

v3.0.2

Published

- [MaiLogger](#mailogger) - [TOC](#toc) - [Features](#features) - [Installation](#installation) - [Usage](#usage) - [API](#api) - [Constructor](#constructor) - [ConstructorOption](#constructoroption)

Downloads

33

Readme

MaiLogger

TOC

MaiLogger is a flexible and easy-to-use logging module for JavaScript applications. It provides output in the format [LOG_LEVEL] yyyy/mm/dd HH:MM:SS messages by default.

Features

  • Customizable log levels (TRACE, DEBUG, INFO, WARN, ERROR)
  • Locale support for date and time formatting
  • Color-coded log output for both browser and Node.js environments

Installation

Install the module via npm:

npm i @shiraya-ma/mai-logger

Usage

Import and create an instance of MaiLogger:

import { MaiLogger } from '@shiraya-ma/mai-logger';

const log = new MaiLogger({ level: 0, locale: 'ja-JP' });
// or const log = new MaiLogger({ level: 'TRACE', locale: 'ja-JP' });

log.trace('hello world!', 'this is MaiLogger');

This will output:

[TRACE] 2024/05/23 17:00:00 hello world! this is MaiLogger

API

Constructor

constructor(option?: MaiLogger.ConstructorOption)

ConstructorOption

| Option | Type | Default | Description | | :-: | :-: | :-: | :- | | level | number | LogLevel | "INFO" | The most detailed log level to output. | | locale | Intl.LocalesArgument | "ja-JP" | Locale to which the date and time displayed in the log conform. |

Log Levels

| Log Level | Description | | :-: | :- | | TRACE | Most detailed information, typically of interest only when diagnosing problems. | | DEBUG | Detailed information on the flow through the system. | | INFO | Interesting runtime events (startup/shutdown). | | WARN | Use of deprecated APIs, poor use of API, 'almost' errors, other runtime |situations that are undesirable or unexpected, but not necessarily wrong. | ERROR | Other runtime errors or unexpected conditions. |

Methods

trace(...message: any)

Outputs trace level logs.

debug(...message: any)

Outputs debug level logs.

info(...message: any)

Outputs info level logs.

warn(...message: any)

Outputs warning level logs.

error(...message: any)

Outputs error level logs.

Examples

Basic Usage

import { MaiLogger } from '@shiraya-ma/mai-logger';

const log = new MaiLogger({ level: 'DEBUG' });
// or const log = new MaiLogger({ level: 1 });

log.debug('This is a debug message');
log.info('This is an info message');
log.warn('This is a warning message');
log.error('This is an error message');

Advanced Usage

import { MaiLogger } from '@shiraya-ma/mai-logger';

const log = new MaiLogger({ level: 'DEBUG' });
// or const log = new MaiLogger({ level: 1 });

log.trace('Trace message will not be shown');
log.debug('This is a debug message');
log.info('This is an info message');
log.warn('This is a warning message');
log.error('This is an error message');

License

This project is licensed under the MIT License - see the LICENSE file for details.