All Projects → jotavejv → stylish-log

jotavejv / stylish-log

Licence: other
🎉 Stylish-log "A beautiful way to see your web console logs"

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to stylish-log

WeConsole
功能全面、界面与体验对标 Chrome devtools 的可定制化的小程序开发调试面板
Stars: ✭ 137 (+1041.67%)
Mutual labels:  debugger, console
gdb-dashboard
Modular visual interface for GDB in Python
Stars: ✭ 8,699 (+72391.67%)
Mutual labels:  debugger, console
Eruda
Console for mobile browsers
Stars: ✭ 11,547 (+96125%)
Mutual labels:  debugger, console
debug.js
Debugger of JavaScript, by JavaScript, for JavaScript
Stars: ✭ 19 (+58.33%)
Mutual labels:  debugger, console
Ruby jard
Just Another Ruby Debugger. Provide a rich Terminal UI that visualizes everything your need, navigates your program with pleasure, stops at matter places only, reduces manual and mental efforts. You can now focus on real debugging.
Stars: ✭ 669 (+5475%)
Mutual labels:  debugger, console
Pry
A runtime developer console and IRB alternative with powerful introspection capabilities.
Stars: ✭ 6,351 (+52825%)
Mutual labels:  debugger, console
console
a debugger for async rust!
Stars: ✭ 2,101 (+17408.33%)
Mutual labels:  debugger, console
std
stdout, for humans.
Stars: ✭ 17 (+41.67%)
Mutual labels:  console
CLI-Autocomplete
Cross-platform flexible autocomplete library for your CLI applications.
Stars: ✭ 21 (+75%)
Mutual labels:  console
vim-easydebugger
A VIM multi-language debugger plugin
Stars: ✭ 47 (+291.67%)
Mutual labels:  debugger
multitextor
Multiplatform command line text editor.
Stars: ✭ 27 (+125%)
Mutual labels:  console
nadbg
👀Dynamic memory watcher/tracer/analyzer for CTF pwn
Stars: ✭ 51 (+325%)
Mutual labels:  debugger
x-terminal
An xterm based Atom plugin for providing terminals inside your Atom workspace.
Stars: ✭ 34 (+183.33%)
Mutual labels:  console
barecolor
A tiny JavaScript utility for printing colorful console messages.
Stars: ✭ 20 (+66.67%)
Mutual labels:  console
app
Buggregator is a beautiful, lightweight debug server build on Laravel that helps you catch your smpt, sentry, var-dump, monolog, ray outputs. It runs without installation on multiple platforms.
Stars: ✭ 259 (+2058.33%)
Mutual labels:  debugger
leeks.js
Simple ANSI styling for your terminal
Stars: ✭ 12 (+0%)
Mutual labels:  console
laravel-console-spinner
Customized loading ⌛ spinner for Laravel Artisan Console.
Stars: ✭ 70 (+483.33%)
Mutual labels:  console
apollo
microcontroller-based FPGA / JTAG programmer
Stars: ✭ 32 (+166.67%)
Mutual labels:  debugger
oof
Convenient, high-performance RGB color and position control for console output
Stars: ✭ 764 (+6266.67%)
Mutual labels:  console
douban.fm
简洁的豆瓣电台命令行版。
Stars: ✭ 13 (+8.33%)
Mutual labels:  console

stylish-log

A stylish console.log

Transform your console.log into a customized logs. This does not override the default console.log, it just add a new way to debug with CSS styles.

How to install

npm install stylish-log

Then you call it with import or require:

import log from 'stylish-log'

//OR

const log = require('stylish-log');

How to use

There are 4 stylish-log methods that you can use:

  • log.show
  • log.info
  • log.warn
  • log.danger

The default styles for these methods are:

const styles = {
  default: 'color: gray; font-weight: bold;',
  info: 'color: blue; font-weight: bold;',
  warn: 'color: #ffc107;',
  danger: 'color: lightcoral; font-weight: bold;'
}

Basic examples

See how this example are shown in console

log.show('default')();
log.info('info')();
log.warn('warn')();
log.danger('danger')();

demo1

You can pass how many values you want to stylish-log methods, if you have more than just one, the first string message becomes a "label message" for your log. Take a look:

const arrObj = [
  {
    "obj1": "lorem value",
    "obj2": "lorem value"
  },
  {
    "obj1_2": "lorem value",
    "obj2_2": "lorem value"
  }
]
const arr = ['arr', 'arr2', 'arr3'];

const fn = function(){
  console.log('A function');
}

//call stylish-log for each value passing a custom message label

log.show('label message:', arrObj)();
log.info('label message:', arr)();
log.warn('label message:', arr, arrObj)();
log.danger('label message:', fn)();

See how this example are shown in console

demo2

How to change the default style

You have total freedom to override the default styles for each method

log.styles.default = 'font-size: 14px; color: #795548; text-transform: uppercase;';
log.styles.info = 'font-size: 14px; background: #4fc3f7; color: white;';
log.styles.warn = 'font-size: 14px; color: black; background: linear-gradient(to right, #ffa726, #ffe0b2)';
log.styles.danger = 'font-size: 14px; color: white; text-shadow: 0 1px 0 black, 0 0 8px red;';

demo3

As you can see even gradients are supported.

Another example with images:

log.styles.default = 'background: url(https://i.imgflip.com/1plo8j.jpg) left bottom no-repeat; background-size: contain; display: block; padding: 150px 80px';

log.show('')();

Assuming that the padding is respectively height and width you can set an image to console. In this case the default style was overrided and then log.show('')() was called, passing an empty string to initiate the image log.

demo4;

What about emojis? Yes you can!

log.styles.default = 'font-size: 50px;';

log.show('🐴', 'go horse')();

demo5

Important

You should have noticed about the double ()() call from the methods in the examples. There was an initial version (not published) that you could just call the methods with single (), the reason of the double ()() are the stack trace in the console. You can see the difference between below:

log.show('testing single () call');

stack2

log.show('testing double ()() call')();

stack4

Why?

In fact, this module is just a stylish console.log which provides a simple way to customize your logs with CSS styles. You can take the same effect using the example console.log(%c My log message, 'color: gray; font-weight: bold;') this will generate the same result as log.show('My log message')().

If you prefer an elegant and useful way to style your console, feel free to use and enjoy it.

TODO

  • Custom methods
  • Preview improvements
  • Icons

A special thanks to @UltCombo
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].