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

smart-log-node

v1.1.5

Published

A simple logging utility that makes simultaneous console and database logging easy.

Readme

smart-log-node

A simple logging utility that makes simultaneous console and database logging easy. Smart log was built with TypeScript but is compatible with both TypeScript and vanilla JavaScript projects. This README file is a first draft. Additional documentation will be coming in the future

Last Updated 01/05/2025

Getting Started

Smart log was build to allow for a single log function to produce a console log in addition to logging in database, file or both. This tool will also, add details and colors to console logs.

Key Concepts

  • Log Instances - All logging config is stored in a single log instance, that can be imported throughout an app.
  • Log Instance Settings - The default log settings will likely work for most apps, however they can be changed if desired.
  • Console Log - A console log is just a standard JS console log, though Smart Log Node will add details and colors.
  • Data Log - Any log logic in addition to Console Logs that is defined in a log definition. This can be database or file logging for example. Smart Log Node deliberately keeps data logging simple and vague (A generic function) in order to allow the developer to have full control.
  • Log Level - Logs are categorized into levels. Levels will help determine the console log color and are recommended to be used when producing data logs.
  • Log Definition - A name combined with a function that contains the Data Log logic. If using Typescript, this is where Data Log function input types can be defined. This allows developers to maintain type safety when writing logs to databases or files.

Configuration Defaults and Types

defaultSettings: SmartLogSettings = {
    debugLogsEnabled: false,
    consoleLoggingEnabled: true,
    consoleLevelLength: 10,
    consoleNameLength: 15,
    consoleDateTimeEnabled: true,
    dataLoggingEnabled: true
};

defaultLogLevelDebugName: string = 'debug';

defaultLogLevels: LogLevels = [
    'info',
    'success',
    'warn',
    'error'
];

defaultConsoleColors: ColorMap = {
    reset: '',
    bold: '',
    red: '',
    green: '',
    yellow: '',
    blue: '',
    magenta: '',
    cyan: '',
    orange: ''
};

defaultConsoleLogDefinitions: ConsoleLogDefinition[] = [
    {
        level: "debug",
        color: 'cyan'
    },
    {
        level: "info",
        color: 'blue'
    },
    {
        level: "success",
        color: 'green'
    },
    {
        level: "warn",
        color: 'yellow'
    },
    {
        level: "error",
        color: 'red'
    }
]

Import, create, and configure a new logging instance

import { createSmartLogInstance } from 'smart-log-node';

const logInstance = createSmartLogInstance();

logInstance.setSettings({
    consoleLevelLength: 15,
    consoleNameLength: 20,
    consoleDateTimeEnabled: false
})

Create a new log definition (Using "System" as the log definition example)

logInstance.addDefinition({
    definitionName: 'system',
    dataLogFunction: async (logInput) => {
        /**
         * 
         * Database, file, or other logging logic should be placed here.
         * 
         */
    }
})

Create a smart log (Non-blocking)

logInstance.smartLog(
    level: 'info',
    definitionName: 'system',
    content: {
        message: 'System log message.'
        consoleLogMessage: 'System log message for console'
    },
    displayedContentKeys: [
        'consoleLogMessage'
    ]
)

Create a smart log (Blocking)

logInstance.smartLogAwait(
        level: 'info',
    definitionName: 'system',
    content: {
        message: 'System log message.'
    }
)

Create a console only log with details and level colors

logInstance.consoleLog(
    level: 'info',
    name: 'system',
    message: 'Console log message'
)

Create a console only log with NO details default log level color

logInstance.consoleLog('Console log message')