logvis

Minimal lightweight logging for TypeScript/JavaScript, adding reliable log level methods to any available console.log methods

Usage no npm install needed!

<script type="module">
  import logvis from 'https://cdn.skypack.dev/logvis';
</script>

README

logvis

Globals

logvis

TypeScript/JavaScript promise queue client library with concurrency control

Installation

Install with npm:

$ npm install --save logvis

Install with yarn:

$ yarn add logvis

Demo

Try online demo

Documentation

Try online documentation

Classes

logvis

Globals / Logger

Class: Logger

Hierarchy

  • Logger

Implements

  • Console

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

+ new Logger(ns: string): Logger

Defined in index.ts:34

Parameters:
Name Type Default value
ns string ""

Returns: Logger

Properties

Console

Readonly Console: any = Logger

Defined in index.ts:34


LEVEL

Readonly LEVEL: typeof LEVEL = LEVEL

Defined in index.ts:32

Accessors

level

• get level(): LEVEL

Defined in index.ts:59

Returns: LEVEL

• set level(level: LEVEL): void

Defined in index.ts:63

Parameters:
Name Type
level LEVEL

Returns: void


memory

• get memory(): any

Defined in index.ts:48

Returns: any


namespace

• get namespace(): string

Defined in index.ts:52

Returns: string

Methods

assert

assert(condition?: undefined | false | true, ...data: any[]): void

Defined in index.ts:105

A simple assertion test that verifies whether value is truthy. If it is not, an AssertionError is thrown. If provided, the error message is formatted using util.format() and used as the error message.

Parameters:
Name Type
condition? undefined | false | true
...data any[]

Returns: void


clear

clear(): void

Defined in index.ts:116

When stdout is a TTY, calling logger.clear() will attempt to clear the TTY. When stdout is not a TTY, this method does nothing.

Returns: void


count

count(label?: undefined | string): void

Defined in index.ts:125

Maintains an internal counter specific to label and outputs to stdout the number of times logger.count() has been called with the given label.

Parameters:
Name Type
label? undefined | string

Returns: void


countReset

countReset(label?: undefined | string): void

Defined in index.ts:134

Resets the internal counter specific to label.

Parameters:
Name Type
label? undefined | string

Returns: void


debug

debug(...data: any[]): void

Defined in index.ts:143

The logger.debug() function is an alias for {@link console.log()}.

Parameters:
Name Type
...data any[]

Returns: void


dir

dir(item?: any, options?: any): void

Defined in index.ts:154

Uses {@link util.inspect()} on obj and prints the resulting string to stdout. This function bypasses any custom inspect() function defined on obj.

Parameters:
Name Type
item? any
options? any

Returns: void


dirxml

dirxml(...data: any[]): void

Defined in index.ts:163

This method calls {@link console.log()} passing it the arguments received. Please note that this method does not produce any XML formatting

Parameters:
Name Type
...data any[]

Returns: void


disableAll

disableAll(): void

Defined in index.ts:89

Returns: void


enableAll

enableAll(): void

Defined in index.ts:85

Returns: void


error

error(...data: any[]): void

Defined in index.ts:173

Prints to stderr with newline.

Parameters:
Name Type
...data any[]

Returns: void


exception

exception(message?: undefined | string, ...optionalParams: any[]): void

Defined in index.ts:180

Parameters:
Name Type
message? undefined | string
...optionalParams any[]

Returns: void


getLogger

getLogger(ns: string): Logger

Defined in index.ts:77

Parameters:
Name Type
ns string

Returns: Logger


getLoggers

getLoggers(): Dictionary<Logger>

Defined in index.ts:81

Returns: Dictionary<Logger>


group

group(...data: any[]): void

Defined in index.ts:190

Increases indentation of subsequent lines by two spaces. If one or more labels are provided, those are printed first without the additional indentation.

Parameters:
Name Type
...data any[]

Returns: void


groupCollapsed

groupCollapsed(...data: any[]): void

Defined in index.ts:200

The logger.groupCollapsed() function is an alias for {@link console.group()}.

Parameters:
Name Type
...data any[]

Returns: void


groupEnd

groupEnd(): void

Defined in index.ts:210

Decreases indentation of subsequent lines by two spaces.

Returns: void


info

info(...data: any[]): void

Defined in index.ts:219

The {@link console.info()} function is an alias for {@link console.log()}.

Parameters:
Name Type
...data any[]

Returns: void


log

log(...data: any[]): void

Defined in index.ts:229

Prints to stdout with newline.

Parameters:
Name Type
...data any[]

Returns: void


noConflict

noConflict(): Logger

Defined in index.ts:93

Returns: Logger


ns

ns(ns: string): Logger

Defined in index.ts:69

Parameters:
Name Type
ns string

Returns: Logger


profile

profile(label?: undefined | string): void

Defined in index.ts:300

This method does not display anything unless used in the inspector. Starts a JavaScript CPU profile with an optional label.

Parameters:
Name Type
label? undefined | string

Returns: void


profileEnd

profileEnd(label?: undefined | string): void

Defined in index.ts:311

This method does not display anything unless used in the inspector. Stops the current JavaScript CPU profiling session if one has been started and prints the report to the Profiles panel of the inspector.

Parameters:
Name Type
label? undefined | string

Returns: void


table

table(tabularData?: any, properties?: string[]): void

Defined in index.ts:240

This method does not display anything unless used in the inspector. Prints to stdout the array array formatted as a table.

Parameters:
Name Type
tabularData? any
properties? string[]

Returns: void


time

time(label?: undefined | string): void

Defined in index.ts:249

Starts a timer that can be used to compute the duration of an operation. Timers are identified by a unique label.

Parameters:
Name Type
label? undefined | string

Returns: void


timeEnd

timeEnd(label?: undefined | string): void

Defined in index.ts:258

Stops a timer that was previously started by calling {@link console.time()} and prints the result to stdout.

Parameters:
Name Type
label? undefined | string

Returns: void


timeLog

timeLog(label?: undefined | string, ...data: any[]): void

Defined in index.ts:267

For a timer that was previously started by calling {@link console.time()}, prints the elapsed time and other data arguments to stdout.

Parameters:
Name Type
label? undefined | string
...data any[]

Returns: void


timeStamp

timeStamp(label?: undefined | string): void

Defined in index.ts:323

This method does not display anything unless used in the inspector. Adds an event with the label label to the Timeline panel of the inspector.

Parameters:
Name Type
label? undefined | string

Returns: void


trace

trace(...data: any[]): void

Defined in index.ts:277

Prints to stderr the string 'Trace :', followed by the {@link util.format()} formatted message and stack trace to the current position in the code.

Parameters:
Name Type
...data any[]

Returns: void


warn

warn(...data: any[]): void

Defined in index.ts:287

The {@link console.warn()} function is an alias for {@link console.error()}.

Parameters:
Name Type
...data any[]

Returns: void

Enums

logvis

Globals / LEVEL

Enumeration: LEVEL

Index

Enumeration members

Enumeration members

DEBUG

DEBUG:

Defined in index.ts:15


ERROR

ERROR:

Defined in index.ts:18


INFO

INFO:

Defined in index.ts:16


SILENT

SILENT:

Defined in index.ts:13


TRACE

TRACE:

Defined in index.ts:14


WARN

WARN:

Defined in index.ts:17

logvis

Globals

logvis

Index

Namespaces

Enumerations

Classes

Interfaces

Type aliases

Variables

Type aliases

Dictionary

Ƭ Dictionary<TValue>: IDictionary<TValue>

Defined in index.ts:10

Type parameters:

Name
TValue

Variables

logger

Const logger: Logger = new Logger()

Defined in index.ts:336


namespaces

Const namespaces: Dictionary<Logger>

Defined in index.ts:21

Interfaces

logvis

Globals / __global / Window

Interface: Window

Hierarchy

  • Window

Index

Properties

Properties

logger

logger: Logger

Defined in index.ts:3

logvis

Globals / IDictionary

Interface: IDictionary<TValue>

Type parameters

Name
TValue

Hierarchy

  • IDictionary

Indexable

▪ [key: string]: TValue

Modules

logvis

Globals / __global

Namespace: __global

Index

Interfaces