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

log-class

v1.0.6

Published

Help you track the complete process of class member function calls with a single log line.

Readme

log-class

log-class npm version

Help you track the complete process of class member function calls with a single log line.

Usage

import { logClass, setLogLevel } from 'log-class'

setLogLevel(4)

@logClass()
class Manager {
    constructor(name: string, age: number) {
        this._test1 = new Staff(name + ' 1')
        this._test2 = new Staff(name + ' 2')
        this._age = age
    }

    show() {
        this.innerPrint(this._test1, this._age)
        this.innerPrint(this._test2, this._age)
        return `age: ${this._age}`
    }

    private innerPrint(testB: Staff, age: number) {
        testB.print(age)
    }

    private _test1: Staff
    private _test2: Staff
    private _age: number
}

@logClass({ keyName: 'name' })
class Staff {
    constructor(name: string) {
        this.name = name
    }

    readonly name: string

    print(age: number) {
        console.log('  - name:', this.name, 'age:', age)
        return age
    }
}

console.log('** start process **\n')

const testA = new Manager('Staff', 18)
testA.show()

console.log('\n** end process **')

logs generated:

** start process **

/-new Manager("Staff", 18)
|   /-new Staff("Staff 1")
|   \-new Staff{Staff 1}
|   /-new Staff("Staff 2")
|   \-new Staff{Staff 2}
\-new Manager
/-Manager.show()
|   /-Manager.innerPrint([Staff], 18)
|   |   /-Staff{Staff 1}.print(18)
  - name: Staff 1 age: 18
|   |   \-Staff{Staff 1}.print => 18
|   \-Manager.innerPrint => undefined
|   /-Manager.innerPrint([Staff], 18)
|   |   /-Staff{Staff 2}.print(18)
  - name: Staff 2 age: 18
|   |   \-Staff{Staff 2}.print => 18
|   \-Manager.innerPrint => undefined
\-Manager.show => "age: 18"

** end process **

Usage

Set logLevel

Any class with its level <= logLevel will show logs. The default initial logLevel is 0, which means show no logs (except for the classes that claimed their level to be 0). Use environment variable LOG_CLASS_LOG_LEVEL to override it, integers 0 ~ 5 are acceptable.

APIs

/***
 * @param opts          optional parameters for logging
 * @param opts.logger   logger function to use, default is console.log
 * @param opts.level    this class's level, 0 <= level <= 5, if level <= logLevel then show logs, default is 3
 * @param opts.keyName  when logging a class's instance, also show this[keyName] as identifier
 */
const logClass = (opts?: LogClassOpts) => {
    // ...
}

/***
 * @param val           if logClass's val <= logLevel, will show logs. initial logLevel is 0
 */
const setLogLevel = (val: 0 | 1 | 2 | 3 | 4 | 5): void => {
    // ...
}