Minimal lightweight logging for TypeScript/JavaScript, adding reliable log level methods to any available console.log methods
npm install logvis
- logvis
- Installation
- Demo
- Documentation
- Classes
- Class: Logger
- Hierarchy
- Implements
- Index
- Constructors
- Properties
- Accessors
- Methods
- Enums
- Enumeration: LEVEL
- Index
- Enumeration members
- logvis
- Index
- Namespaces
- Enumerations
- Classes
- Interfaces
- Type aliases
- Variables
- Type aliases
- Dictionary
- Variables
- logger
- namespaces
- Interfaces
- Interface: Window
- Hierarchy
- Index
- Properties
- Interface: IDictionary\
- Type parameters
- Hierarchy
- Indexable
- Modules
- Namespace: \_\_global
- Index
> Globals
#### Minimal lightweight logging for TypeScript/JavaScript, adding reliable log level methods to any available console.log methods
Install with npm:
``sh`
$ npm install --save logvis
Install with yarn:
`sh`
$ yarn add logvis
#### Try online demo
> Globals / Logger
* Logger
* Console
#### Constructors
#### Properties
#### Accessors
#### Methods
* assert
* clear
* count
* countReset
* debug
* dir
* dirxml
* disableAll
* enableAll
* error
* exception
* getLogger
* getLoggers
* group
* groupCollapsed
* groupEnd
* info
* log
* noConflict
* ns
* profile
* profileEnd
* table
* time
* timeEnd
* timeLog
* timeStamp
* trace
* warn
#### constructor
\+ new Logger(ns: string): Logger
Defined in index.ts:34
##### Parameters:
Name | Type | Default value |
------ | ------ | ------ |
ns | string | "" |
Returns: Logger
#### Console
• Readonly Console: any = Logger
Defined in index.ts:34
___
#### LEVEL
• Readonly LEVEL: typeof LEVEL = LEVEL
Defined in index.ts:32
#### 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
#### assert
▸ assert(condition?: undefined \| false \| true, ...data: any[]): void
Defined in index.ts:105
A simple assertion test that verifies whether value is truthy.AssertionError
If it is not, an is thrown.message
If provided, the error 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.stdout
When 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.inspect()
This function bypasses any custom 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
> Globals / LEVEL
#### Enumeration members
* DEBUG
* ERROR
* INFO
* SILENT
* TRACE
* WARN
#### 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
> Globals
* LEVEL
* Logger
* logger
* namespaces
Ƭ Dictionary\
Defined in index.ts:10
#### Type parameters:
Name |
------ |
TValue |
• Const logger: Logger = new Logger()
Defined in index.ts:336
___
• Const namespaces: Dictionary\<Logger>
Defined in index.ts:21
> Globals / \_\_global / Window
* Window
#### Properties
* logger
#### logger
• logger: Logger
Defined in index.ts:3
> Globals / IDictionary
Name |
------ |
TValue` |
* IDictionary
▪ [key: string]: TValue
> Globals / \_\_global
#### Interfaces
* Window