1.0.4 • Published 1 year ago

console-hijacker v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

console-hijacker

Installation

npm install console-hijacker

Use Case

whenever you call console.log() it always run the consoleHijacker.Log function

  • Ctrate a new file YOUR_FILENAME.js
  • add the given code
  • import in your root file only one time and use every where

FOR .JS

const { default: consoleHijacker } = require('console-hijacker')

consoleHijacker({
    Log: (data) => {
        // function call when console.log() trigger
   },
    Warn: (data) => {
        // function call when console.warn() trigger
    },
    Info: (data) => {
        // function call when console.info() trigger
    },
    Error: (data) => {
        // function call when console.error() trigger
    },
});

FOR TS

import consoleHijacker, { ConsoleType } from "console-hijacker";

consoleHijacker({
    Log: function (data: ConsoleType): void {
        // function call when console.log() trigger
    },
    Warn: function (data: ConsoleType): void {
        // function call when console.warn() trigger
    },
    Info: function (data: ConsoleType): void {
        // function call when console.info() trigger
    },
    Error: function (data: ConsoleType): void {
        // function call when console.error() trigger
    }
}) 

NOTE: Don't Use console.log(), console.warn(), console.info(), and/or console.error() inside the consoleHijacker function.

WHY NOT: if you use any of these console(s) inside this consoleHijacker function then it run as a loop and through an error of call stack overflow.

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago