02. Log
The log object is a built-in extension object that provides logging output functionality.
Functional overview:
- Able to set output level of the system log.
- Able to set log output destination.
- Allows logging arbitrary messages with JavaScript.
Limitations:
- The maximum storage capacity of the non-volatile memory for logs is
4064KB
.
When full, the old log is overwritten.
log Global Object
Methods()/Properties | Summary | Version | Note |
---|---|---|---|
log.setLevel() | Sets the level and the output destination of the system log. | ||
log.clear() | Clears logs stored in non-volatile memory. | ||
log.getStoredSize() | Gets the size of the currently saved log. | ||
log.getStorageSize() | Gets the storage size available for logs. | ||
log.printLevel() | Sets the output destination of the print() function. | ||
print() | Prints the log message. | This is a globally scoped function. |
Details
log.setLevel([level[,output[,instance]]])
Sets the level and the output destination of the system log.
The last set value is saved in non-volatile memory.
Therefore, it is possible to simply leave the system log disabled.
This method is used to investigate potential causes when unexpected behaviors occur.
Name | Type | M/O | Summary | Note | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
level | number | optional | Log level setting -1: Disabled 0: Error level 1: Warning level 2: Debug level 3: Trace level The default value is -1. | |||||||||
output | number | optional | Output destination setting 0: All disabled 1: Saves the log to the non-volatile memory on the NEQTO device 2: Outputs to the NEQTO daemon log 3: Enable 1 and 2 4: Sends the log to NEQTO Console in real time 5: Enable 1 and 4 6: Enable 2 and 4 7: Enable 1, 2 and 4 The default value is 0. | The "Send log to NEQTO Console in real time" function should be used for debugging purposes only. Since this function uses many communication resources, it may increase the processing load on the device and cause data transmission delays. In addition, as there are no retransmission processes in cases of communication failures, it may result in lost log data. | ||||||||
instance | number | optional, mandatory | Specify the instance ID to which the real-time log will be sent on the NEQTO Console. For the available range of instance IDs, refer here. | It is mandatory only if 'output' is 4 or above. Real-time logs will be sent to the NEQTO Console using the following MQTT specification:
| ||||||||
return | undefined | - | - | When an error occurs, an exception is raised. |
log.clear()
Clears the logs stored in non-volatile memory.
Name | Type | M/O | Summary | Note |
---|---|---|---|---|
return | undefined | - | - |
log.getStoredSize()
Gets the size of the currently saved log.
Name | Type | M/O | Summary | Note |
---|---|---|---|---|
return | number | - | Log size currently saved [byte]. |
log.getStorageSize()
Gets the amount of storage available to save logs.
Name | Type | M/O | Summary | Note |
---|---|---|---|---|
return | number | - | Log size that can be saved [byte]. |
log.printLevel([output[,instance]])
Sets the output destination of the print() function.
This print level is always initialized with default values at the start of script execution.
Name | Type | M/O | Summary | Note | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
output | number | optional | Output destination setting 0: All disabled 1: Saves the log to the non-volatile memory on the NEQTO device 2: Outputs to the NEQTO daemon log 3: Enable 1 and 2 4: Sends the log to NEQTO Console in real time 5: Enable 1 and 4 6: Enable 2 and 4 7: Enable 1, 2 and 4 The default value is 0. | The "Send log to NEQTO Console in real time" function should be used for debugging purposes only. Since this function uses many communication resources, it may increase the processing load on the device and cause data transmission delays. In addition, as there are no retransmission processes in cases of communication failures, it may result in lost log data. | ||||||||
instance | number | optional, mandatory | Specify the instance ID to which the real-time log will be sent on the NEQTO Console. For the available range of instance IDs, refer here. | It is mandatory only if 'output' is 4 or above. Real-time logs will be sent to the NEQTO Console using the following MQTT specification:
| ||||||||
return | undefined | - | - | When an error occurs, an exception is raised. |
print(logMsg)
Prints the log message.
Name | Type | M/O | Summary | Note |
---|---|---|---|---|
logMsg | string | mandatory | Message to output as log. | |
return | undefined | - | - | When an error occurs, an exception is raised. |
Object Usage Examples
Sample 1
This is a sample that outputs the system log and print log to the NEQTO daemon log.
log.setLevel(0,2);
log.printLevel(2);
Sample 2
This is a sample that sends the system log and print log to NEQTO Console in real time.
The instance ID is an arbitrary value. It is also possible to use the same ID for the system log and the print log.
log.setLevel(0,4,1);
log.printLevel(4,2);
//log.printLevel(4,1); /*Available*/