- Installation
- Synopsis
- Details
- API
- Classes
- Class: Log
- Class: LogGroup
- Enums
- Enumeration: LogLevel
- Interfaces
- Interface: GroupRecord
- Interface: LogRecord
npm install spy-log
Format | Instructions |
---|---|
TypeScript | import Log from "spy-log"; |
Node (CommonJS) | const { Log } = require("spy-log"); |
ES Modules (Browsers, webpack) | import Log from "spy-log"; |
import Log from 'spy-log';
async function subTask(logger) {
logger.info('massage in suntask');
await request('http://example.com', logger.group('getExample'));
logger.end();
}
const logger = new Log('main');
logger.log('main start');
subTask(logger.group('subtask'));
Renames and exports: Log
Ƭ RecordType: LogRecord | GroupRecord
Log-records stored in LogGroup.records
Defined in: index.ts:48
spy-log / Log
-
Log
↳ LogGroup
+ new Log(namespace
: string): Log
Name | Type |
---|---|
namespace |
string |
Returns: Log
Defined in: index.ts:69
• Protected
Optional
curStage: string
Defined in: index.ts:72
• Protected
namespace: string
▪ Static
console: Console
Defined in: index.ts:68
▪ Static
getLogFn: (level
: LogLevel) => (...data
: any[]) => void
▸ (level
: LogLevel): function
Name | Type |
---|---|
level |
LogLevel |
Returns: (...data
: any[]) => void
Defined in: index.ts:62
Defined in: index.ts:69
▸ debug(...args
: any[]): void
Name | Type |
---|---|
...args |
any[] |
Returns: void
Defined in: index.ts:79
▸ error(...args
: any[]): void
Name | Type |
---|---|
...args |
any[] |
Returns: void
Defined in: index.ts:95
▸ group(name
: string): LogGroup
Name | Type |
---|---|
name |
string |
Returns: LogGroup
Defined in: index.ts:121
▸ info(...args
: any[]): void
Name | Type |
---|---|
...args |
any[] |
Returns: void
Defined in: index.ts:87
▸ log(...args
: any[]): void
Name | Type |
---|---|
...args |
any[] |
Returns: void
Defined in: index.ts:83
▸ print(message
: any[], level
: LogLevel, stage?
: undefined | string, inGroup?
: boolean): void
Name | Type |
---|---|
message |
any[] |
level |
LogLevel |
stage |
undefined | string |
inGroup? |
boolean |
Returns: void
Defined in: index.ts:99
▸ printGroup(name
: string, records
: RecordType[], collapsed
: boolean): void
Name | Type |
---|---|
name |
string |
records |
RecordType[] |
collapsed |
boolean |
Returns: void
Defined in: index.ts:106
▸ stage(str
: string): Log
Name | Type |
---|---|
str |
string |
Returns: Log
Defined in: index.ts:74
▸ warn(...args
: any[]): void
Name | Type |
---|---|
...args |
any[] |
Returns: void
Defined in: index.ts:91
spy-log / LogGroup
-
↳ LogGroup
+ new LogGroup(name
: string, parent
: Log | LogGroup, collapsed?
: boolean): LogGroup
Name | Type | Default value |
---|---|---|
name |
string | - |
parent |
Log | LogGroup | - |
collapsed |
boolean | false |
Returns: LogGroup
Inherited from: Log
Defined in: index.ts:128
• Protected
Optional
curStage: string
Defined in: index.ts:72
• Protected
namespace: string
▪ Static
console: Console
Defined in: index.ts:68
▪ Static
getLogFn: (level
: LogLevel) => (...data
: any[]) => void
▸ (level
: LogLevel): function
Name | Type |
---|---|
level |
LogLevel |
Returns: (...data
: any[]) => void
Defined in: index.ts:62
Defined in: index.ts:69
▸ debug(...args
: any[]): void
Name | Type |
---|---|
...args |
any[] |
Returns: void
Inherited from: Log
Defined in: index.ts:79
▸ end(): void
Returns: void
Defined in: index.ts:150
▸ error(...args
: any[]): void
Name | Type |
---|---|
...args |
any[] |
Returns: void
Inherited from: Log
Defined in: index.ts:95
▸ group(name
: string): LogGroup
Name | Type |
---|---|
name |
string |
Returns: LogGroup
Inherited from: Log
Defined in: index.ts:121
▸ info(...args
: any[]): void
Name | Type |
---|---|
...args |
any[] |
Returns: void
Inherited from: Log
Defined in: index.ts:87
▸ log(...args
: any[]): void
Name | Type |
---|---|
...args |
any[] |
Returns: void
Inherited from: Log
Defined in: index.ts:83
▸ print(message
: any[], level
: LogLevel, stage?
: undefined | string): void
Name | Type |
---|---|
message |
any[] |
level |
LogLevel |
stage |
undefined | string |
Returns: void
Overrides: Log
Defined in: index.ts:133
▸ printGroup(name
: string, records
: RecordType[], collapsed
: boolean): void
Name | Type |
---|---|
name |
string |
records |
RecordType[] |
collapsed |
boolean |
Returns: void
Overrides: Log
Defined in: index.ts:142
▸ stage(str
: string): LogGroup
Name | Type |
---|---|
str |
string |
Returns: LogGroup
Inherited from: Log
Defined in: index.ts:74
▸ warn(...args
: any[]): void
Name | Type |
---|---|
...args |
any[] |
Returns: void
Inherited from: Log
Defined in: index.ts:91
spy-log / LogLevel
LogLevel.Log is identical to LogLevel.Info
see
https://developers.google.com/web/tools/chrome-devtools/console/reference#level
• Error: = 4
Defined in: index.ts:11
• Info: = 2
Defined in: index.ts:9
• Log: = 1
Defined in: index.ts:8
• Verbose: = 0
Defined in: index.ts:7
• Warning: = 3
Defined in: index.ts:10
spy-log / GroupRecord
• collapsed: boolean
except the group is initially collapsed when it's logged to the Console
Defined in: index.ts:38
• name: string
name of a log-group
> [namespace]name
····[stage]message in a group
Defined in: index.ts:34
• records: RecordType[]
records in a log-group
Defined in: index.ts:42
spy-log / LogRecord
• level: LogLevel
Defined in: index.ts:23
• message: any[]
messages to print
Defined in: index.ts:22
• Optional
stage: string
stage of a log-record
[namespace][stage]message
Defined in: index.ts:20
• time: Date
Defined in: index.ts:24