The Logger control interface is used to create file logs into the log
folder of the current storage volume.
The following API is asynchronous and using Promise.
To use this API, you first need to get the logger control interface thanks to IDAL.getControlInterfaces().
Methods
delete(id) → {Promise.<boolean>|Promise.<ErrorStatus>}
Delete a log file.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The identifier of the log file to delete (basically: a filename). |
Returns:
-
A promise resolved with a
boolean
value.- Type
- Promise.<boolean>
-
A promise rejected with an ErrorStatus.
- Type
- Promise.<ErrorStatus>
list() → {Promise.<Array.<string>>|Promise.<ErrorStatus>}
Get the list of existing log identifiers.
Returns:
-
A promise resolved with an array of strings, each element being a log identifier.
- Type
- Promise.<Array.<string>>
-
A promise rejected with an ErrorStatus.
- Type
- Promise.<ErrorStatus>
log(id, message) → {Promise.<boolean>|Promise.<ErrorStatus>}
Log a message into a given log file.
The message is stored in a file on the current storage media into the log
folder.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The identifier of the log file (basically: a filename). |
message |
string | The message to write into the file. |
Returns:
-
A promise resolved with a
boolean
value.- Type
- Promise.<boolean>
-
A promise rejected with an ErrorStatus.
- Type
- Promise.<ErrorStatus>
read(id, offset, length) → {Promise.<Logger~ReadInfo>|Promise.<ErrorStatus>}
Read the content of a log.
You can use this method to retrieve the content of the log, for example if you
need to push them to a remote server.
The returned data are Base64 encoded (and not raw strings) to avoid issues when the
data are encoding multibyte characters.
When there are no more data to read, this call will return a ReadInfo
with a zero length
.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The identifier of the log file to read. |
offset |
number | The read offset. |
length |
number | The maximum number of bytes that can be read. |
Returns:
-
A promise resolved with the log data.
- Type
- Promise.<Logger~ReadInfo>
-
A promise rejected with an ErrorStatus.
- Type
- Promise.<ErrorStatus>
stat(id) → {Promise.<Logger~StatInfo>|Promise.<ErrorStatus>}
Get the status of a log (size).
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The identifier of the log file to query for status. |
Returns:
-
A promise resolved with the log status.
- Type
- Promise.<Logger~StatInfo>
-
A promise rejected with an ErrorStatus.
- Type
- Promise.<ErrorStatus>
Type Definitions
ReadInfo
A ReadInfo Contains the result of a call to Logger.read().
Properties:
Name | Type | Description |
---|---|---|
data |
string | Is a Base64 string encoding the data read from a log file. |
length |
number | Is the number of bytes that have been read. Beware, this is not the
length of |
StatInfo
A StatInfo Contains the result of a call to Logger.stat().
Properties:
Name | Type | Description |
---|---|---|
size |
number | Is the size (number of bytes) of the log file. |