-
-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
optimization of log string generation #2292
base: master
Are you sure you want to change the base?
Conversation
let has_debug = ! isMsg_from_zigbee && this.checkDebugDevice(devId); | ||
|
||
if (has_debug){ | ||
this.warn(`ELEVATED publishToState: message received '${JSON.stringify(payload)}' from device ${devId} type '${model}'`); |
Check notice
Code scanning / CodeQL
Semicolon insertion Note
the enclosing function
@@ -1086,7 +1106,9 @@ | |||
if (typeof data === 'string') { | |||
logger(`${msg}. ${data}`); | |||
} else { | |||
logger(`${msg}. ${safeJsonStringify(data)}`); | |||
if (this.log.level==level) | |||
logger(`${msg}. ${safeJsonStringify(data)}`) |
Check notice
Code scanning / CodeQL
Semicolon insertion Note
the enclosing function
Thank you for the pull request. I have a number of questions and requests:
Please note that I am aware of the fact that the PTVO implementation with dynamic states is an outlier as far as integration goes - an elevated logging good for the PTVO type devices will generate far too much data for 'standard' devices, but PTVO devices make less than 1% of the active devices. A. |
I think the bot has an issue with missing ;, especially in if then else constructs. But I am not sure about it. As it is not that easy for me to modify the files, I'd thought to ask you to look into this and fix it.
This is a misconception. The device debug was explicitly introduced to allow tracking data sent to and from a device without putting the entire adapter in debug mode. As such, it should generate as few messages as sensible, not as detailed as possible, in order for us to be able to document the expected message flow and pinpoint issues to people who have no experience with the entire process. Any detailed analysis still requires for the adapter to be run in debug mode.
My idea was to move the check, ensuring that the elevated messages only come when debug messages do not come. This removes the need to check for each message if to send it to the elevated warning or debug message, and the code can simply call the debug message function without any additional check. Now this does not mean that the existing check must be removed - but it is no longer required in such a scenario. A. |
serialization of objects via JSON.stringify method may consume unnecessary resources.
This is especially noticed for the PIVO firmware, where the serialized "entity" object takes up to 90 kbytes. and it is called very often