@cmolina/log
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

@cmolina/log

Keep track for when functions are being called and when they returned.

Quickstart

Install the dependency

npm i -D @cmolina/log

Log your functions

import { log } from '@cmolina/log';
import { myFunction } from './some-local-module';

// 1. wrap your function
const myFunctionWithLogs = log(myFunction);

// 2. use your wrapped function as expected
myFunctionWithLogs('pass', 'the', 'original', 'parameters');

// 3. see the logs in your console!
/*
    myFunction('pass', 'the', 'original', 'parameters') started
    myFunction('pass', 'the', 'original', 'parameters') returned '😁'
*/

Log your methods

import { log } from '@cmolina/log';
import { MyClass } from './some-local-module';

const myInstance = new MyClass();

// 1. wrap your instance
const myInstanceWithLogs = log(myInstance);

// 2. use your wrapped method as expected
myInstanceWithLogs.myMethod('pass', 'the', 'original', 'parameters');

// 3. see the logs in your console!
/*
    MyClass.myMethod('pass', 'the', 'original', 'parameters') started
    MyClass.myMethod('pass', 'the', 'original', 'parameters') returned '😲'
*/

Readme

Keywords

Package Sidebar

Install

npm i @cmolina/log

Weekly Downloads

1

Version

0.2.0

License

MIT

Unpacked Size

15.5 kB

Total Files

8

Last publish

Collaborators

  • cmolina