0.1.3 • Published 6 years ago

@reactual/c v0.1.3

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

c (:art:)

A console.log prettifier for node.js

Notice

Currently under development/unreleased, not for use in production.

Installation

Published as an npm module under the @reactual organization.

yarn add @reactual/c

# or via npm

npm install --save @reactual/c

Usage

There are a few possible ways to use c within a project:

Import Directly As Needed

Import or require from @reactual/c in each file as needed. Since c is a default export, you can use any variable name you prefer.

/** ES6 imports */
import c from '@reactual/c'

/** or any var preferred */
import log from '@reactual/c'


/** ES5 require */
const c = require('@reactual/c')

/** or any var preferred */
const log = require('@reactual/c')

Logging messages

Replace normal console.log statements with examples below.

const total = 2 + 2

// console.log('The total is:', total

c('The total is:', total)

Specifying a log level

The most basic usage is to not specify a log level. c defaults to info, or error if the value being logged is an instance of a node.js Error. You can also force a specific log level by passing a 3rd argument.

const total = 2 + 2

/** level unspecified, defaults to "info" for values that aren't instances of Error */
c('info unspecified example, total:', total)

/** info, forced with abbreviation */
c('info example, total:', total, 'i')

/** info, forced with full word */
c('info, full word example, total:', total, 'info')

/** warn, forced with abbreviation */
c('warning example, total:', total, 'w')

/** error, forced with abbreviation */
c('error example, total:', total, 'e')

/** level unspecified, defaults to "error" for instances of Error */
c('error unspecified example, total:', new Error(total))

Valid values for log level, You can use the full name or abbreviation:

  • info | i
  • warn | w
  • error | e

If you pass an invalid value for level, c will ignore it and fallback to info or error depending on the value being logged.

In addition to instances of Error, the below error classes will default to the error level.

  • AssertionError
  • RangeError
  • ReferenceError
  • SyntaxError
  • TypeError
0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago