2.7.3 • Published 10 months ago

@microphi/debug v2.7.3

Weekly downloads
-
License
-
Repository
-
Last release
10 months ago

@microphi/debug

Super simple wrapper around console.log

Install

@microphi/debug

Use in nodejs

import { getDebugger } from "@microphi/debug";

export const d = getDebugger('namespace1');

// any where in the code
d('test');
setTimeout(() => {
  d('hello there');
}, 500);

Set DEBUG environment variable with a comma separated list of regex: if a match happens with a namespace then the text will be logged using console.log.

nodejs example output

Use in the browser

Set localStorage.debug with a comma separated list of regex: if a match happens with a namespace then the text will be logged using console.log.

browser example output

In this case localStorage.debug is set to musicbox:*

OnMessage handler

With OnMessage is possible to handle each message logged regardless of the regexes provided. This may be usefull to send the logs to a server or to to store them to a file.

onMessage((message) => {
  // do something
});
2.7.3

10 months ago

2.7.2

1 year ago

2.7.1

1 year ago

2.6.0

1 year ago

2.5.1

1 year ago

2.3.0

1 year ago

2.2.1

1 year ago

2.2.3

1 year ago

2.2.0

1 year ago

1.2.0

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago