console-with-style

    1.1.0 • Public • Published

    console-with-style

    %c (CSS styling) support for Node's console.log

    Why?

    Firefox, Chrome's and Safari's console support styling console.log output with CSS declarations. Node should to!

    How?

    It translates CSS styles to ansi escape sequences for the terminal!

    Example

    const supportsColor = require('supports-color')
    const level = (supportsColor.stdout && supportsColor.stdout.level) || 0
    const format = require('console-with-style')(level)
    console.log(format('%ci=%d%c, %cs="%s"%c, %cCSS', 'color:yellow;', 5, 'color:inherit;', 'background: blue;', 'hello','background: inherit', 'color: orange;'))

    So far, only colors are supported.

    Ok ... why again?

    If you forward the output of a browser's console to a process in the terminal, it's nice to see the same colors, for example when using debug.

    License

    MIT

    Install

    npm i console-with-style

    DownloadsWeekly Downloads

    40

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    77.9 kB

    Total Files

    10

    Last publish

    Collaborators

    • regular