Home Reference Source Test

Function

Static Public Summary
public

Transform an error into a user-readable, colored string.

public

fromEnv(options: Object, env: Object, environment: string): Log

Utility function that will create a new instance of Log with options taken from environment variables.

public

indent(string: string, length: number, char: string): string

Add characters at the begenning of every line of a multi-line string.

Static Public

public formatError(error: Error): string source

import {formatError} from 'hiplog/src/index.js'

Transform an error into a user-readable, colored string.

Params:

NameTypeAttributeDescription
error Error

Input error.

Return:

string

The formatted message.

public fromEnv(options: Object, env: Object, environment: string): Log source

import {fromEnv} from 'hiplog/src/index.js'

Utility function that will create a new instance of Log with options taken from environment variables.

Variables:

  • NODE_ENV:
    • 'development' (default): displayTime is disabled,
    • 'test': displayTime is disabled, 'level' is set to 'critical',
    • 'production': Use default values for each option.
  • LOG: Sets level value.
  • LOG_LEVEL: Alias for LOG.
  • LOG_TIME: When set to true or 1, enables displayTime.
  • LOG_TIME_FORMAT: Sets displayTimeFormat value.

Params:

NameTypeAttributeDescription
options Object
  • optional
  • default: {}

Additional options. Will take precedence over other ones.

env Object
  • optional
  • default: process.env || {}

env object.

environment string
  • optional
  • default: env.NODE_ENV || 'development'

Environment.

Return:

Log

A new instance of Log.

Test:

public indent(string: string, length: number, char: string): string source

import {indent} from 'hiplog/src/index.js'

Add characters at the begenning of every line of a multi-line string.

Params:

NameTypeAttributeDescription
string string

Input string.

length number

Number of characters to insert at every line.

char string
  • optional
  • default: ' '

Character to insert.

Return:

string

The indented string.