# console-hijack

> Modify native console object to emit events and set verbosity

Latest version **0.0.1** (published 2017-07-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install console-hijack
pnpm add console-hijack
yarn add console-hijack
bun add console-hijack
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2017-07-20 |
| First published | 2017-07-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6 <7 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Alan Languirand |
| Maintainers | 13protons |
| Keywords | streams, writeable stream, data, readable stream, streaming |

## Links

- npm: https://www.npmjs.com/package/console-hijack
- Repository: https://github.com/alanguir/console-hijack
- Homepage: https://github.com/alanguir/console-hijack#readme
- Issues: https://github.com/alanguir/console-hijack/issues
- npm.io page: https://npm.io/package/console-hijack

## Dependencies (1)

- [loglevel](https://npm.io/package/loglevel.md) ^1.4.1

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2017-07-20

## README

# Console-hijack
[![Build Status](https://travis-ci.org/alanguir/console-hijack.svg?branch=master)](https://travis-ci.org/alanguir/console-hijack)

Intercepting and modifying common console printing methods in the browser. Why? To receive callback events when methods like `console.log` or `console.error` are called, and to mute native console methods (like log) in production.

## Installation

> NOTE: This module is still under development! Use in production at your own risk!

```
npm install console-hijack
```

...Then Include `dist/console-hijack.js` in your project. See examples for more info.

## Usage

Including this script on your page automatically hijacks the following console methods: [LOG, INFO, WARN, ERROR, TRACE];

To receive a callback for a given method, simply listen to it:

```
document.addEventListener('console.log', callback);
console.log('hi mom'); // will trigger callback, and log to console!
```

#### callback(payload)

The callback function is invoked with a payload that has the following signature:

```
{
  type: [String], // the method called, like 'console.log'
  messages: [Array] // an array of all arguments passed - `console.log('hi', 'mom')` becomes `['hi', 'mom']`
}
```

#### log level

Set the log level to mute everything below that level. For example, setting the log level to WARN will mute LOG and INFO. The default level is LOG

```
console.hijack.level = console.hijack.WARN
```

#### Stop/Start

The console object can be restored by calling `console.hijack.stop()`. No more events will be fired and the previously intercepted methods will be returned to their original state. Resume hijacking by calling `console.hijack.start()`

---
_Source: https://npm.io/package/console-hijack · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
