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

@yassine-essiyedali/autologging

v0.1.1

Published

A powerful library for cutomizable auto-logging and functions auto-tracing.

Readme

autologging

A powerful TypeScript/JavaScript library for customizable auto-logging and function auto-tracing with support for both synchronous and asynchronous functions.

npm version License: MIT

Features

Function Wrapper - Wrap any function with automatic logging
🎯 Method Decorator - Decorate class methods with @tracable
🏗️ Class Decorator - Trace entire classes with @tracableClass
Async Support - Works seamlessly with both sync and async functions
⏱️ Execution Time Tracking - Automatically measures and logs execution time
📊 Parameter Logging - Logs function parameters automatically

Installation

npm install @yassine-essiyedali/autologging

Usage

Function Wrapper

Wrap any function to add automatic tracing:

import { trace } from 'autologging';

function add(a: number, b: number): number {
  return a + b;
}

const tracedAdd = trace(add);
tracedAdd(5, 3);

Output:

Function started
parameters
arg0 = 5
arg1 = 3
Execution time: 0.123
Function ended

Method Decorator

Use @tracable to automatically trace class methods:

import { tracable } from 'autologging';

class Calculator {
  @tracable()
  multiply(a: number, b: number): number {
    return a * b;
  }

  @tracable()
  async divide(a: number, b: number): Promise<number> {
    return a / b;
  }
}

const calc = new Calculator();
calc.multiply(4, 5);
await calc.divide(10, 2);

Class Decorator

Trace specific methods in a class using @tracableClass:

import { tracableClass } from 'autologging';

@tracableClass(['processData', 'calculate'])
class DataProcessor {
  processData(data: string): string {
    return data.toUpperCase();
  }

  calculate(x: number): number {
    return x * 2;
  }

  // This method won't be traced
  helperMethod(): void {
    console.log('Helper');
  }
}

const processor = new DataProcessor();
processor.processData('hello'); // Traced
processor.calculate(10);        // Traced
processor.helperMethod();       // Not traced

TypeScript Configuration

Enable decorators in your tsconfig.json:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

API Reference

trace<T, R>(fn: (...args: T) => R)

Wraps a function with automatic logging and execution time tracking.

Parameters:

  • fn - The function to wrap

Returns:

  • A wrapped version of the function with tracing enabled

@tracable()

Method decorator that adds automatic tracing to class methods.

Usage:

@tracable()
methodName() { ... }

@tracableClass(functionsToTrace: string[])

Class decorator that traces specific methods in a class.

Parameters:

  • functionsToTrace - Array of method names to trace

Usage:

@tracableClass(['method1', 'method2'])
class MyClass { ... }

Customization

The library uses constants from LoggingConstants which include:

  • FUNCTION_STARTED - "Function started"
  • FUNCTION_ENDED - "Function ended"
  • PARAMETERS_LABEL - "parameters"
  • EXECUTION_TIME - "Execution time"

Examples

Async Function Support

import { trace } from 'autologging';

async function fetchData(url: string): Promise<any> {
  const response = await fetch(url);
  return response.json();
}

const tracedFetch = trace(fetchData);
await tracedFetch('https://api.example.com/data');

Multiple Methods

import { tracable } from 'autologging';

class UserService {
  @tracable()
  async getUser(id: number): Promise<User> {
    // ... fetch user
  }

  @tracable()
  async updateUser(id: number, data: UserData): Promise<User> {
    // ... update user
  }
}

Requirements

  • TypeScript 5.0+
  • Node.js 14+

License

MIT © Yassine ESSIYEDALI

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Issues

Found a bug or have a feature request? Open an issue

Repository

https://github.com/yassine-ess/autoLogging