Logger
Extends:
The logger class. Please note that, when importing default from this module, you will always get a shared Logger instance.
See:
Test:
Static Member Summary
Static Public Members | ||
public static get |
The default log types. |
Constructor Summary
Public Constructor | ||
public |
constructor(options: Object) Creates a new Logger with the given options. |
Member Summary
Public Members | ||
public |
The log level where no messages are printed. |
|
public |
The log levels available. |
|
public |
Prints the given messages for the given message types. |
|
public |
colors: chalk The colors used. |
|
public get |
The message prefix. |
Private Members | ||
private |
The log types available. |
Method Summary
Public Methods | ||
public |
pipe(stream: stream~Writable, options: Object): Logger Writes all logs to a writable stream. |
|
public |
typesForLevel(logLevel: number): string[] Returns the log types that should be handled for the specific log level. |
Private Methods | ||
private |
Creates a log message from some messages, prefixed and postfixed with a newline. |
Public Constructors
Public Members
public [type](messages: ...*): Logger: * source
Prints the given messages for the given message types.
Emit:
Emits an event named after |
Example:
Logger.on('warn', msg => console.log('Warning:', msg))
.warn('Test warning');
// Will print "Waring: Test warning" to the console.
public get prefix: string source
The message prefix. Override this getter in your own logger class to customize output.
Test:
Private Members
Public Methods
public pipe(stream: stream~Writable, options: Object): Logger source
Writes all logs to a writable stream.
Params:
Name | Type | Attribute | Description |
stream | stream~Writable | The stream to write to |
|
options | Object |
|
The options to use. |
options.logLevel | number |
|
The log level from which to write. |
Example:
Logger.pipe(process.stdout);
Logger.pipe(process.stdout, { logLevel: Logger.LEVEL_ERROR });
// In this case, only error messages will be printed to stdout
Test:
public typesForLevel(logLevel: number): string[] source
Returns the log types that should be handled for the specific log level.
Params:
Name | Type | Attribute | Description |
logLevel | number | The log level to use. |