import RemoteDeviceLogger from 'remote-device-logger/remote-device-logger/index.js'RemoteDeviceLogger
Create a logger
Example:
const logger = new RemoteDeviceLogger();
logger.log('Log A', 'Log B');
Constructor Summary
| Public Constructor | ||
| public |
constructor(params: Object) |
|
Member Summary
| Private Members | ||
| private |
_connection: Object The WebSocket connection |
|
| private |
_element: HTMLElement The log container element |
|
| private |
_logPool: Array The pool area to store log messages |
|
| private |
_stdout: boolean The condition if print a log message to the standard output |
|
Method Summary
| Public Methods | ||
| public |
hide() Hide the log container element |
|
| public |
log(messages: ...any) Log messages |
|
| public |
print(messages: ...any) Print messages |
|
| public |
sendLog(messages: string[]) Send log messages |
|
| public |
show() Show the log container element |
|
| public |
toggle() Toggle the log container element |
|
| public |
writeToElement(messages: string[]) Write log messages to the log container element |
|
| Private Methods | ||
| private |
Add an event lister to window to catch all errors happening on the browser |
|
| private |
_connectWebSocket(url: string) Connect to a WebSocket server where you want to send a log |
|
| private |
_createElement(parentElement: HTMLElement, display: boolean) Create an element node to contain logs for display |
|
Public Constructors
public constructor(params: Object) source
Params:
| Name | Type | Attribute | Description |
| params | Object | ||
| params.debug | boolean |
|
debug |
| params.stdout | boolean |
|
stdout |
| params.element | HTMLElement |
|
element |
| params.webSocketUrl | string |
|
webSocketUrl |
| params.display | boolean |
|
display |
Private Members
Public Methods
public log(messages: ...any) source
Log messages
Params:
| Name | Type | Attribute | Description |
| messages | ...any | Log messages |
public print(messages: ...any) source
Print messages
Params:
| Name | Type | Attribute | Description |
| messages | ...any | Messages to print |
public sendLog(messages: string[]) source
Send log messages
Params:
| Name | Type | Attribute | Description |
| messages | string[] | Messages to send |
public writeToElement(messages: string[]) source
Write log messages to the log container element
Params:
| Name | Type | Attribute | Description |
| messages | string[] | Messages to write |
Private Methods
private _catchAllErrors() source
Add an event lister to window to catch all errors happening on the browser
private _connectWebSocket(url: string) source
Connect to a WebSocket server where you want to send a log
Params:
| Name | Type | Attribute | Description |
| url | string | The URL of a WebSocket server |
private _createElement(parentElement: HTMLElement, display: boolean) source
Create an element node to contain logs for display
Params:
| Name | Type | Attribute | Description |
| parentElement | HTMLElement | The parent element of the log node |
|
| display | boolean | The initial state of the logs' appearance |
