smarthome icon indicating copy to clipboard operation
smarthome copied to clipboard

Visu subscription of a memory log activates sending of env.core.log

Open onkelandy opened this issue 1 year ago • 5 comments

handlers:
    memory_warn:
        (): lib.log.ShngMemLogHandler
        logname: memory_warn
        maxlen: 60
        level: WARNING
        filters: [stateengine, roborock, roborock_2, standby]
root:
    level: WARNING
    handlers: [shng_warnings_file, memory_warn]

and

{{ status.log('', 'memory_warn', 20) }}

results in correct subscription of the memory log on loading the visu page. However, as soon as the log gets updated (new entry added), the smartvisu also receives data from env.core.log which results in a console error. Maybe websocket exceptions also result from this behaviour or it's just a "cosmetic" issue..?

@wvhn could confirm that behaviour.

onkelandy avatar Sep 18 '23 19:09 onkelandy

Yes. I have configured a Memory Log handler as described in the docu („mem_heiz“) and attached this to plugins.uzsu. SmarthomeNG delivers the right data but then sends additional updates for env.core.log. The console error is thrown because env.core.log is not subscribed and thus not initialized in the widget.buffer.

wvhn avatar Sep 18 '23 20:09 wvhn

Das Problem kommt wohl von der Funktion initMemLog im log.py Hier wird fix ein entsprechender Memory Logger erstellt, was ja prinzipiell keine schlechte Idee ist, da man dann das entsprechende memory log ohne weiteres Zutun in smartvisu einbinden kann. Wenn man es aber nicht einbindet, kommt es eben zu besagtem Fehler.

onkelandy avatar Nov 05 '23 20:11 onkelandy

Ich stecke da jetzt nicht drin - aber warum muss env.core.log pauschal als memlog bereitgestellt werden? Soweit ich den Code verstehe, werden ja auch keine anderen Logs verarbeitet, oder?

Morg42 avatar Mar 03 '24 15:03 Morg42

Dieses Log wird standardmäßig von der smartVISU verwendet (auf der Seite Konfiguration/SmartHomeNG)

msinn avatar Mar 04 '24 08:03 msinn

Ich habe nochmal weiter getestet, indem ich einen weiteren memlog angelegt habe ('mem_webs'). Beim Abrufen des ursprünglichen Logs "mem_heiz" wird zunächst nur dessen Inhalt per Websocket übertragen. Soweit korrekt.

Sobald anschließend neue Einträge in "env.core.log" oder "mem_webs" erfolgen, werden diese als Updates übertragen obwohl sie nicht abonniert sind. Offenbar prüft die Update-Methode der memlogs nicht bzw. nich korrekt, welche Logs abonniert sind.

Ich habe jetzt einen workaround im smarthomeNG-Treiber von smartVISU erstellt, der die Fehlermeldung vermeidet und statt dessen eine Meldung auf der Konsole ausgibt:

console.log('[io.smarthomeng] ignoring data for not requested log "' + data.name + '"');

Die Änderung ist im smartVISU develop branch.

Dennoch sollte der bug in smarthomeNG behoben werden.

wvhn avatar Mar 04 '24 12:03 wvhn