Constructor
new Logger(messagesPrefixopt, showTimeopt)
- Source:
- Tutorials:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
messagesPrefix |
string |
<optional> |
''
|
A prefix to include in front of all the messages. |
showTime |
boolean |
<optional> |
false
|
Whether or not to show the time on each message. |
Members
messagesPrefix :string
- Source:
The prefix to include in front of all the messages.
Type:
showTime :boolean
- Source:
Whether or not to show the time on each message.
Type:
warn :function
- Source:
- See:
An alias for the Logger#warning
method.
Type:
Methods
error(message, exceptionopt)
- Source:
Logs an error (red) message or messages on the console.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
message |
LoggerMessage | Error | A single message of a list of them.
See the |
||
exception |
Object |
<optional> |
null
|
If the exception has a |
info(message)
- Source:
- See:
Logs an information (gray) message or messages on the console.
Parameters:
Name | Type | Description |
---|---|---|
message |
LoggerMessage | A single message of a list of them. |
log(message, coloropt)
- Source:
Logs a message with an specific color on the console.
Example
// Simple
CLILogger.log('hello world');
// Custom color
CLILogger.log('It was the shadow who did it', 'red');
// A list of messages all the same color
CLILogger.log(["Ph'nglu", "mglw'nafh"], 'grey');
// A list of messages with different colors per line
CLILogger.log(
[
"Ph'nglu",
"mglw'nafh",
['Cthulhu', 'green'],
["R'lyeh wgah'nagl fhtagn", 'red'],
],
'grey',
);
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
message |
LoggerMessage | A text message to log or a list of them. |
||
color |
string |
<optional> |
'raw'
|
Optional. The color of the message (the default is the terminal default). This can be overwritten line by line when the message is an array, take a look at the example. |
prefix(text) → {string}
- Source:
Prefixes a message with the text sent to the constructor and, if enabled, the current time.
Parameters:
Name | Type | Description |
---|---|---|
text |
string | The text that needs the prefix. |
Returns:
- Type
- string
success(message)
- Source:
- See:
Logs a success (green) message or messages on the console.
Parameters:
Name | Type | Description |
---|---|---|
message |
LoggerMessage | A single message of a list of them. |
warning(message)
- Source:
- See:
Logs a warning (yellow) message or messages on the console.
Parameters:
Name | Type | Description |
---|---|---|
message |
LoggerMessage | A single message of a list of them. |