logger

Dead-simple, composable, isomorphic, cross-browser wrapper for console.log.

> log('Colorful ', bold(red('R'), green('G'), blue('B')), ' logs are ', underline('very'), ' easy!');
< Colorful RGB logs are very easy!
Source:

Classes

Message

Members

(static) consoleStyles :Object

Source:
Properties:
Name Type Description
bold module:logger.ConsoleStyle

bold text

dim module:logger.ConsoleStyle

text dimmed by 20%

italic module:logger.ConsoleStyle

italic text

underline module:logger.ConsoleStyle

underlined text

inverse module:logger.ConsoleStyle

inverted colors

hidden module:logger.ConsoleStyle

invisible

strikethrough module:logger.ConsoleStyle

strikethrough

black module:logger.ConsoleStyle

black text color

red module:logger.ConsoleStyle

red text color

green module:logger.ConsoleStyle

green text color

yellow module:logger.ConsoleStyle

yellow text color

blue module:logger.ConsoleStyle

blue text color

magenta module:logger.ConsoleStyle

magenta text color

cyan module:logger.ConsoleStyle

cyan text color

white module:logger.ConsoleStyle

white text color

gray module:logger.ConsoleStyle

gray text color

grey module:logger.ConsoleStyle

gray text color

bgBlack module:logger.ConsoleStyle

black background color

bgRed module:logger.ConsoleStyle

red background color

bgGreen module:logger.ConsoleStyle

green background color

bgYellow module:logger.ConsoleStyle

yellow background color

bgBlue module:logger.ConsoleStyle

blue background color

bgMagenta module:logger.ConsoleStyle

magenta background color

bgCyan module:logger.ConsoleStyle

cyan background color

bgWhite module:logger.ConsoleStyle

white background color

Console style helpers.

Type:
  • Object

Methods

(static) log(…messages)

Source:

Log colorful messages out to the console on Node.js as well as in a browser in the simplest and most composable way.

Example
import {log, consoleStyles} from 'webcompiler';
// or - import {log, consoleStyles} from 'webcompiler/lib/logger';
// or - var webcompiler = require('webcompiler');
//      var log = webcompiler.log;
//      var consoleStyles = webcompiler.consoleStyles;
// or - var logger = require('webcompiler/lib/logger');
//      var log = logger.log;
//      var consoleStyles = logger.consoleStyles;

const {red, green, blue, bold, underline} = consoleStyles;

log('Colorful ', bold(red('R'), green('G'), blue('B')), ' logs are ', underline('very'), ' easy!');
Parameters:
Name Type Attributes Description
messages string | number | module:logger.Message <repeatable>

messages to log

(static) logError(error)

Source:

Prints an Error object out to the console.

Removes irrelevant entries from its stack trace that point to Node.js system files that you would never debug anyway and hence are irrelevant.

Example
import {logError} from 'webcompiler';
// or - import {logError} from 'webcompiler/lib/logger';
// or - var logError = require('webcompiler').logError;
// or - var logError = require('webcompiler/lib/logger').logError;

logError(new Error('Some error message'));
Parameters:
Name Type Description
error Error

an error object

(static) logLintingErrors(errors, prefixopt)

Source:

Prints linting errors out to the console.

Example
import {logLintingErrors} from 'webcompiler';
// or - import {logLintingErrors} from 'webcompiler/lib/logger';
// or - var logLintingErrors = require('webcompiler').logLintingErrors;
// or - var logLintingErrors = require('webcompiler/lib/logger').logLintingErrors;
Parameters:
Name Type Attributes Default Description
errors Array.<LintError>

error objects

prefix string <optional>
null

will be printed on the last line along with the total number of messages

(static) logPostCSSWarnings(warnings)

Source:

Prints PostCSS Warning objects out to the console.

Example
import {logPostCSSWarnings} from 'webcompiler';
// or - import {logPostCSSWarnings} from 'webcompiler/lib/logger';
// or - var logPostCSSWarnings = require('webcompiler').logPostCSSWarnings;
// or - var logPostCSSWarnings = require('webcompiler/lib/logger').logPostCSSWarnings;
import postcss from 'postcss';

postcss(...).process(...).then(result => {
  const warnings = result.warnings();

  if (warnings.length) {
    return logPostCSSWarnings(warnings);
  }
  ...
});
Parameters:
Name Type Description
warnings Array.<PostCSSWarning>

warning objects

(static) logSASSError(error)

Source:

Prints a Node SASS error object out to the console.

Example
import {logSASSError} from 'webcompiler';
// or - import {logSASSError} from 'webcompiler/lib/logger';
// or - var logSASSError = require('webcompiler').logSASSError;
// or - var logSASSError = require('webcompiler/lib/logger').logSASSError;
import {render} from 'node-sass';

render(..., (error, result) => {
  if (error) {
    return logSASSError(error);
  }
  ...
});
Parameters:
Name Type Description
error NodeSassError

error object

(static) logSequentialSuccessMessage(message)

Source:

Within the current process logs green colored messages out to the console prepending a sequential number starting with "1." to the message, to make it easier to distinguish messages containing the same text.

Example
import {logSequentialSuccessMessage} from 'webcompiler';
// or - import {logSequentialSuccessMessage} from 'webcompiler/lib/logger';
// or - var logSequentialSuccessMessage = require('webcompiler').logSequentialSuccessMessage;
// or - var logSequentialSuccessMessage = require('webcompiler/lib/logger').logSequentialSuccessMessage;
Parameters:
Name Type Description
message string

a message to log

Type Definitions

ConsoleStyle(…messages) → {module:logger.Message}

Source:
Parameters:
Name Type Attributes Description
messages string | number | module:logger.Message <repeatable>

messages to log

Returns:

a styled message

Type
module:logger.Message