All Projects â†’ samsonradu â†’ console-subscriber

samsonradu / console-subscriber

Licence: MIT license
Subscribe to the browser's console output.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to console-subscriber

ansicolor
A JavaScript ANSI color/style management. ANSI parsing. ANSI to CSS. Small, clean, no dependencies.
Stars: ✭ 91 (+550%)
Mutual labels:  console, console-log
ptkdev-logger
đŸĻ’ Beautiful Logger for Node.js: the best alternative to the console.log statement
Stars: ✭ 117 (+735.71%)
Mutual labels:  console, console-log
console-logging
Better, prettier commandline logging for Python--with colors! đŸ‘ģ
Stars: ✭ 111 (+692.86%)
Mutual labels:  console, console-log
douban.fm
įŽ€æ´įš„蹆į“Ŗį”ĩ台å‘Ŋäģ¤čĄŒį‰ˆã€‚
Stars: ✭ 13 (-7.14%)
Mutual labels:  console
yachalk
🖍ī¸ Terminal string styling done right
Stars: ✭ 131 (+835.71%)
Mutual labels:  console
colorize
pub.dartlang.org/packages/colorize
Stars: ✭ 20 (+42.86%)
Mutual labels:  console
mini-me
Inline multiline text-editor/prompt written in Rust.
Stars: ✭ 23 (+64.29%)
Mutual labels:  console
alerta-webui
Alerta Web UI 7.0
Stars: ✭ 84 (+500%)
Mutual labels:  console
console
a debugger for async rust!
Stars: ✭ 2,101 (+14907.14%)
Mutual labels:  console
laravel-console-spinner
Customized loading ⌛ spinner for Laravel Artisan Console.
Stars: ✭ 70 (+400%)
Mutual labels:  console
xplr
A hackable, minimal, fast TUI file explorer
Stars: ✭ 2,271 (+16121.43%)
Mutual labels:  console
px
ps and top for human beings
Stars: ✭ 151 (+978.57%)
Mutual labels:  console
CLI-Autocomplete
Cross-platform flexible autocomplete library for your CLI applications.
Stars: ✭ 21 (+50%)
Mutual labels:  console
tput.cr
Low-level component for building term/console applications in Crystal
Stars: ✭ 22 (+57.14%)
Mutual labels:  console
oof
Convenient, high-performance RGB color and position control for console output
Stars: ✭ 764 (+5357.14%)
Mutual labels:  console
fpga-virtual-console
VT220-compatible console on Cyclone IV EP4CE55F23I7
Stars: ✭ 33 (+135.71%)
Mutual labels:  console
Inquirer.cs
A collection of common interactive command line user interfaces. Port of Inquirer.js
Stars: ✭ 26 (+85.71%)
Mutual labels:  console
log-utils
Basic logging utils: colors, symbols and timestamp.
Stars: ✭ 24 (+71.43%)
Mutual labels:  console
stylish-log
🎉 Stylish-log "A beautiful way to see your web console logs"
Stars: ✭ 12 (-14.29%)
Mutual labels:  console
wt-console
A lightweight, extendable react-native developer and tester tool
Stars: ✭ 31 (+121.43%)
Mutual labels:  console

Console subscriber

A drop-in tool to subscribe to the console output. Useful for debugging JS scripts on a device where the console is not easily accessible like mobile device browsers, or even in Node environments.

Installation

npm

npm install console-subscriber

script

<script src="node_modules/console-subscriber/index.js"></script>

Usage

let cs = require('console-subscriber'); // window.ConsoleSubscriber object is available in browsers

/**
 * Function to be called on console output
 * WARNING: calling console.log inside the callback would lead to an infinite recursion
 *
 * @param string $category info|warn|error|debug
 * @param array $args initial arguments of the call 
 */
let callback = (category, args) => {

    // In a browser env you could write to a DOM element
    let message = category + ": " + JSON.stringify(args) + "\n";
    document.getElementById('console').innerHTML += message; 

    // In a Node env you could store the console output (errors)
    if (category === "error"){
        redisClient.sadd("console:error", JSON.stringify(args));
    }
};

// Bind callback fn. Multiple functions can be bound.
cs.bind(callback); 

// Unbind a previously bound callback
cs.unbind(callback);

// Restore defaults
cs.unbind();    

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].