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

mk-simple-logger

v0.1.11

Published

Simple logger for node

Readme

MK Simple Logger

MK Simple Logger Verified on Openbase

npm npm Libraries.io dependency status for latest release

This a small package for node that allow implement a logger, and add same config options, like theming or set custom format.

ℹ️ℹ️ Since versión 0.1.11 the output is formatted for logger's name and log's level

Install

The package is available in npm repositories. npm install

npm install mk-simple-logger

yarn install

yarn add mk-simple-logger

Usage

The main class is SimpleLogger so you need to import from the module

const SimpleLogger = require("mk-simple-logger").SimpleLogger;
// or
const { SimpleLogger } = require('mk-simple-logger');
let logger = new SimpleLogger("mylogger");
logger.info("My Message");
// -> 20/02/2021 @ 20:10:40 - [ info ] - mylogger - My message

// allow string foramtting
logger.critical("My {p} message", { p: "custom" });
// -> 20/02/2021 @ 20:10:40 - [ CRITICAL ] - mylogger - My custom message

Methods

logger.debug("");
logger.info("");
logger.log("");
logger.warn("");
logger.error("");
logger.critical("");

Set the log level

SimpleLogger.setLogLevel("debug"); // 'warn'| 'info' | 'log' | 'error' |
'critical'

Set custom format

The class allow change the date and the log line format:

SimpleLogger.setFormat("{name} ==> {msg}");
// on log: mylogger ==> My message
SimpleLogger.setDateFormat("{y}/{month}/{day}");
// on write date: 21/03/14

Available log fields:

{name}  - logger name
{level} - loging level
{date}  - log date
{msg}   - log message

Available date format:

{day}     - current day
{weekDay} - day of the week
{month}   - the month
{year}    - the full year
{y}       - the short year
{hour}    - the hour
{min}     - the minuts
{sec}     - the seconds
{mil}     - the miliseconds

Enable the file logger

SimpleLogger class can manger a file log too, this option need to set the static option isFile as true and set the logFile:

SimpleLogger.enableFileLog(); // enable file log
SimpleLogger.setFileLog("myapp.log"); //setting the file log
// if you want you can disable the stdout with:
SimpleLogger.disableStdout();

Logger can work with two options at the same time, they'r not restrictive.

Load configuration from the env

Simple logger can load same data from the enviroment if it's set. Can load:

  • LEVEL as logLevel
  • LOG_FILE for set the log's file
  • ERROR_FILE for set the errors' file
  • If NODE_ENV is set read it and set the log level from this env variable

Global usage

It's posible to use the logger globally, for this prupose from version 0.1.4 has the static method global() that return an static instance of the logger:

	const {SimpleLogger} = require('mk-simple-logger');
	SimpleLogger.global().log('message'); // can access to all log method
	SimpleLogger.global().setName('name'); // can set the girglobal logger name

All methods all available for the glogal logger.

Express integration

Sice version 0.1.8 can use built logger for express applications:

function logger(?name: string, ?level: string, ?format: string): ExpressMiddlewar

⚠️❗ Since 0.1.9 you can set a custom format


Usage in express

const express =  require('express');
const app = express();
const {SimpleLogger, logger} = require('mk-simple-logger');
app.use(express.json());
...
app.use(logger("SERVER", "info", "{method} {url} {status} {time}ms"));
...
app.listen(8080);

On request:

GET /uri1
logger:
18-02-22 @ 19:43:50 [ INFO ] -> SERVER -> GET /uri1 300 3ms

The logger work like the main logger so you can enable the file logger.

Format

Since 0.1.9

The format param let you customize the message body, in this case, like the logger format, we have a prefixed mapped data:

| FIELD | Description | |------|----------------| | {time} | Request time | | {method} | Request method | | {url} | Request url | | {status} | Response status code |

You can play with this paramaters to generate a custom log mesage format.