smarthomeNG / smarthome

Device integration platform for your smart home
https://www.smarthomeNG.de
GNU General Public License v3.0
121 stars 92 forks source link

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

Open onkelandy opened 12 months ago

onkelandy commented 12 months ago
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.

wvhn commented 12 months ago

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.

onkelandy commented 10 months ago

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.

Morg42 commented 6 months ago

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?

msinn commented 6 months ago

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

wvhn commented 6 months ago

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.