Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. [Vorlage] JS: Log-Datei aufbereiten für VIS

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    [Vorlage] JS: Log-Datei aufbereiten für VIS

    This topic has been deleted. Only users with topic management privileges can see it.
    • Mic
      Mic Developer @sigi234 last edited by

      @sigi234
      Bei mir läuft das Out of the box von https://raw.githubusercontent.com/Mic-M/iobroker.logfile-script/master/iobroker_logfile-script.js einwandfrei.
      Was hast du denn im Script verändert?
      Bitte mal komplettes Script posten, das du oben verwendest.

      sigi234 1 Reply Last reply Reply Quote 0
      • sigi234
        sigi234 Forum Testing Most Active @Mic last edited by

        @Mic sagte in [Vorlage] JS: Log-Datei aufbereiten für VIS:

        @sigi234
        Bei mir läuft das Out of the box von https://raw.githubusercontent.com/Mic-M/iobroker.logfile-script/master/iobroker_logfile-script.js einwandfrei.
        Was hast du denn im Script verändert?
        Bitte mal komplettes Script posten, das du oben verwendest.

        Skript_Log_sigi234.txt

        Mic 1 Reply Last reply Reply Quote 0
        • Mic
          Mic Developer @sigi234 last edited by Mic

          @sigi234
          So wie es aussieht fehlt bei dir in LOG_FILTER bei "all" die Option jsonDateFormat
          Füge dort das mal hinzu:

          jsonDateFormat: 'dd.mm. hh:mm',
          
          sigi234 1 Reply Last reply Reply Quote 0
          • sigi234
            sigi234 Forum Testing Most Active @Mic last edited by

            @Mic sagte in [Vorlage] JS: Log-Datei aufbereiten für VIS:

            @sigi234
            So wie es aussieht fehlt bei dir in LOG_FILTER bei "all" die Option jsonDateFormat
            Füge dort das mal hinzu:

            jsonDateFormat: 'dd.mm. hh:mm',
            

            Jupp, geht jetzt.

            1 Reply Last reply Reply Quote 0
            • Negalein
              Negalein Global Moderator last edited by

              @Mic

              funktioniert das so, wenn ich nur warn, error und debug möchte?

                // /*
                //  {
                //    id:             'hubschrauberlandeplatz',
                //    filter_all:     ['hubschr.0'],
                //    filter_any:     ['wetterwarnung', 'alarm', 'ufo'],
                //    blacklist:      ['0 Bft', '1 Bft', '2 Bft', '3 Bft', '4 Bft'],
                //    clean:          ['****', '!!!!', 'ufo gesichtet'],
                //    merge:          true,
                //    sortDescending: true,
                //    jsonDateFormat: 'dd.mm. hh:mm',       
                //    jsonColumns:    ['source','date','msg'],
                //    jsonLogLength:  100,
                //    jsonMaxLines:   10,
                //    jsonCssToLevel: true,
                //  }, 
                // */
              
                // /*
                //   {
                //     id:             'all',    // Beispiel "all": hier kommen alle Logeinträge rein, keine Filterung
                //     filter_all:     ['', ''], // wird ignoriert, wenn leer
                //     filter_any:     ['', ''], // wird ignoriert, wenn leer
                //     blacklist:      ['', ''], // wird ignoriert, wenn leer
                //     clean:          ['', '', ''], // wird ignoriert, wenn leer
                //     merge:          true,
                //     sortDescending: true,
                //     jsonColumns:    ['date','level','source','msg'],  // Spaltenreihenfolge für JSON (Tabelle in vis)
                //     jsonLogLength:  100,
                //     jsonMaxLines:   10,
                //     jsonCssToLevel: true,
                //   },
                // */
                //   {
                //     id:             'info',
                //     filter_all:     [' - info: '], // nur Logeinträge mit Level 'info'
                //     filter_any:     ['', ''],
                //     blacklist:      ['', ''],
                //     clean:          ['', '', ''],
                //     merge:          true,
                //     sortDescending: true,
                //     jsonDateFormat: 'dd.mm. hh:mm',
                //     jsonColumns:    ['date','level','source','msg'],
                //     jsonLogLength:  100,
                //     jsonMaxLines:   60,
                //     jsonCssToLevel: true,
                //   },
                {
                  id:             'debug',
                  filter_all:     [' - debug: ', ''],  // nur Logeinträge mit Level 'debug'
                  filter_any:     [''],
                  blacklist:      ['', '', ''],
                  clean:          ['', '', ''],
                  merge:          true,
                  sortDescending: true,
                  jsonColumns:    ['date','level','source','msg'],
                  jsonDateFormat: 'dd.mm. hh:mm',
                  jsonLogLength:  100,
                  jsonMaxLines:   60,
                  jsonCssToLevel: true,
                },
                {
                  id:             'warnanderror',
                  filter_all:     ['', ''],
                  filter_any:     [' - error: ', ' - warn: '],  // nur Logeinträge mit Levels 'warn' und 'error'
                  blacklist:      ['', 'no playback content', 'Ignore! Actual secret is '],
                  clean:          ['', '', ''],
                  merge:          true,
                  sortDescending: true,
                  jsonDateFormat: 'dd.mm. hh:mm',
                  jsonColumns:    ['date','level','source','msg'],
                  jsonLogLength:  100,
                  jsonMaxLines:   60,
                  jsonCssToLevel: true,
                },
                //   {
                //     // Beispiel, um einen bestimmten Adapter zu überwachen.
                //     // Hier werden alle Fehler und Warnungen des Homematic-Adapters hm-rpc.0 gelistet.
                //     id:             'homematic',
                //     filter_all:     ['hm-rpc.0', ''],  // hm-rpc.0 muss enthalten sein.
                //     filter_any:     [' - error: ', ' - warn: '],  // entweder error oder warn
                //     blacklist:      ['', '', ''],
                //     clean:          ['', '', ''],
                //     merge:          true,
                //     sortDescending: true,
                //     jsonDateFormat: 'dd.mm. hh:mm',
                //     jsonColumns:    ['date','level','source','msg'],
                //     jsonLogLength:  100,
                //     jsonMaxLines:   60,
                //     jsonCssToLevel: true,
                //   },
              
              ];
              
              Mic 1 Reply Last reply Reply Quote 0
              • Mic
                Mic Developer @Negalein last edited by

                @Negalein
                Bitte nimm die aktualisierte Script-Version 4.0.1. Ich habe dort die Zeile jsonDateFormat: 'dd.mm. hh:mm', unterhalb von LOG_FILTER, "all", ergänzt.

                Ansonsten: Auskommentieren in JavaScript geht mit // für eine einzelne Zeile und mit /* und */ auch für mehrere Zeilen. Der JavaScript-Adapter zeigt das auch schön in grün an, was auskommentiert wurde.

                Das hier

                // log('Test1');
                // log('Test2');
                // log('Test3');
                

                Ist gleich wie

                /*
                log('Test1');
                log('Test2');
                log('Test3');
                */
                

                Beides kommentiert aus, also wird es nicht ausgeführt.

                Kombination geht auch, ist aber unnötig:

                /*
                // log('Test1');
                // log('Test2');
                // log('Test3');
                */
                
                Negalein 1 Reply Last reply Reply Quote 0
                • Negalein
                  Negalein Global Moderator @Mic last edited by

                  @Mic sagte in [Vorlage] JS: Log-Datei aufbereiten für VIS:

                  Ansonsten: Auskommentieren in JavaScript geht mit // für eine einzelne Zeile und mit /* und */ auch für mehrere Zeilen. Der JavaScript-Adapter zeigt das auch schön in grün an, was auskommentiert wurde.

                  Danke für Erklärung.

                  Dieser Teil passt dann?
                  mit { beginnen und mit }, aufhören?

                    {
                      id:             'debug',
                      filter_all:     [' - debug: ', ''],  // nur Logeinträge mit Level 'debug'
                      filter_any:     [''],
                      blacklist:      ['', '', ''],
                      clean:          ['', '', ''],
                      merge:          true,
                      sortDescending: true,
                      jsonColumns:    ['date','level','source','msg'],
                      jsonDateFormat: 'dd.mm. hh:mm',
                      jsonLogLength:  100,
                      jsonMaxLines:   60,
                      jsonCssToLevel: true,
                    },
                    {
                      id:             'warnanderror',
                      filter_all:     ['', ''],
                      filter_any:     [' - error: ', ' - warn: '],  // nur Logeinträge mit Levels 'warn' und 'error'
                      blacklist:      ['', 'no playback content', 'Ignore! Actual secret is '],
                      clean:          ['', '', ''],
                      merge:          true,
                      sortDescending: true,
                      jsonDateFormat: 'dd.mm. hh:mm',
                      jsonColumns:    ['date','level','source','msg'],
                      jsonLogLength:  100,
                      jsonMaxLines:   60,
                      jsonCssToLevel: true,
                    },
                  
                  Mic 1 Reply Last reply Reply Quote 0
                  • Mic
                    Mic Developer @Negalein last edited by

                    @Negalein
                    Ja, alles gut damit 🙂

                    Glasfaser 1 Reply Last reply Reply Quote 0
                    • Glasfaser
                      Glasfaser @Mic last edited by

                      @Mic

                      Habe das neue Skript 4.01 auf meine Punkte angepasst ,

                      nur eins ist mit aufgefallen das der Punkt " WarnundError" nur noch einzeln angezeigt wird , also nicht mehr als Liste untereinander
                      Die Punkte sind unverändert :

                      {
                          id:             'warnanderror',
                          filter_all:     ['', ''],
                          filter_any:     [' - error: ', ' - warn: '],  // nur Logeinträge mit Levels 'warn' und 'error'
                          blacklist:      ['', 'no playback content', 'Ignore! Actual secret is '],
                          clean:          ['', '', ''],
                          merge:          true,
                          sortDescending: true,
                          jsonDateFormat: 'dd.mm. hh:mm',
                          jsonColumns:    ['date','level','source','msg'],
                          jsonLogLength:  100,
                          jsonMaxLines:   60,
                          jsonCssToLevel: true,
                        },
                      
                      

                      So ist es wenn eine Error Meldung kommt :

                      1.JPG

                      und so wenn eine Warnmeldung kommt , dann verschwindet jeweils der andere Eintrag bzw. wechselt .

                      2JPG.JPG

                      So ist es mit der 3.4 Version wie es eigentlich sein sollte
                      .3.JPG

                      Mic 1 Reply Last reply Reply Quote 0
                      • Mic
                        Mic Developer @Glasfaser last edited by

                        @Glasfaser
                        Danke für dein Testen und Feedback. Seltsam, kann ich leider nicht reproduzieren:

                        1. Alle Datenpunkte löschen und frisches Script von Github (Version 4.0.1)
                        2. Noch "Warn" hinzugefügt, dann speichern und Script starten.

                        {
                            id:             'warn',
                            filter_all:     [' - warn: ', ''],
                            filter_any:     [''],
                            blacklist:      ['', '', ''],
                            clean:          ['', '', ''],
                            merge:          true,
                            sortDescending: true,
                            jsonColumns:    ['date','level','source','msg'],
                            jsonDateFormat: 'dd.mm. hh:mm',
                            jsonLogLength:  100,
                            jsonMaxLines:   60,
                            jsonCssToLevel: true,
                          },
                        

                        1. Folgenden Code im JS-Adapter ausführen:
                        log('Error-Meldung', 'error');
                        log('Warn-Meldung', 'warn');
                        // Nochmal nach 2 Sekunden.
                        setTimeout(function() {
                            log('Error-Meldung', 'error');
                            log('Warn-Meldung', 'warn');
                        }, 2*1000);
                        // Nach 30 Sekunden noch eine Warnmeldung.
                        setTimeout(function() {
                            log('Neue Warn-Meldung nach 30 Sekunden', 'warn');
                        }, 30*1000);
                        
                        1. Nun wird angezeigt:

                        Error:
                        x_Error.png

                        Warn:
                        x_Warn.png

                        Warnanderror:
                        x_Warnanderror.png

                        Also so, wie es sein soll. Kannst du das bitte auch mal so testen?

                        1 Reply Last reply Reply Quote 0
                        • Mic
                          Mic Developer last edited by

                          An alle Benutzer dieses Scripts

                          Braucht ihr noch weitere Datenpunkte?
                          Ich habe etwa gesehen, dass ihr manuell Datenpunkte hinzufügt zum Umschalten in VIS. Das könnte ich auch einbauen, also z.B. zusätzlichen Datenpunkt "visCurrentLogId", der dann für ein Auswahl-Widget (Pulldown, etc.) oder für Buttons in VIS dient, um zwischen den einzelnen Logs mittels "Sichtbarkeit" von den Widgets umzuschalten.
                          Zwischenablage01.png

                          Was sonst noch?

                          sigi234 Negalein 3 Replies Last reply Reply Quote 0
                          • sigi234
                            sigi234 Forum Testing Most Active @Mic last edited by

                            @Mic sagte in [Vorlage] JS: Log-Datei aufbereiten für VIS:

                            Ich habe etwa gesehen, dass ihr manuell Datenpunkte hinzufügt zum Umschalten in VIS. Das könnte ich auch einbauen

                            Wäre Cool!

                            Screenshot (1568).png

                            Mic 1 Reply Last reply Reply Quote 0
                            • Negalein
                              Negalein Global Moderator @Mic last edited by

                              @Mic sagte in [Vorlage] JS: Log-Datei aufbereiten für VIS:

                              Braucht ihr noch weitere Datenpunkte?

                              wennst es erweiterst, ist es ganz nett, aber für mich nicht unbedingt notwendig. 🙂

                              1 Reply Last reply Reply Quote 1
                              • Mic
                                Mic Developer @sigi234 last edited by Mic

                                @sigi234 sagte in [Vorlage] JS: Log-Datei aufbereiten für VIS:

                                Wäre Cool!

                                Aber dann wäre es wohl praktischer, dass dann auch automatisch ein Datenpunkt dazu mit ausgewähltem (z.B. "Homematic) JSON gefüllt wird, oder?

                                Denn soweit ich das in VIS blicke, kann eine Widget-Tabelle nur einen bestimmten Datenpunkt abgreifen. Würde gerne den Umweg über "Sichtbarkeit" und mehrere Tabellen vermeiden in VIS, zur einfacheren Implementierbarkeit/Pflege und vor allem wegen VIS-Performance (1 anstatt 5 Tabellen-Widgets übereinander).
                                Also wie in diesem Beispiel von @Glasfaser dann nur noch 1 Tabellen-Widget, anstatt 5 (für Warn_Error, Infologs, Warnlogs, Errorlogs, Zustand).
                                Bild Text

                                sigi234 Glasfaser O 4 Replies Last reply Reply Quote 0
                                • sigi234
                                  sigi234 Forum Testing Most Active @Mic last edited by sigi234

                                  @Mic
                                  Na ja, ich habe ja eine eigene View dafür und sehe so Alle auf einmal.

                                  Übrigens ist debug nicht mehr da?

                                  Mic 1 Reply Last reply Reply Quote 0
                                  • Glasfaser
                                    Glasfaser @Mic last edited by Glasfaser

                                    @Mic

                                    Wäre Interessiert 😉

                                    Da ich @Oli Vis nutze und ein wenig für mich umgebaut habe , währe ich und er auch ganz bestimmt davon beindruckt , da er schon danach gesucht hat es so lösen zu können
                                    , es nicht mehr über die Sichbarkeit schalten zu müssen .

                                    Daher …. das VIS wird nie fertig 🙂

                                    PS : Bin noch am Testen , melde mich später ….

                                    1 Reply Last reply Reply Quote 0
                                    • Glasfaser
                                      Glasfaser @Mic last edited by Glasfaser

                                      @Mic

                                      Mhhh …. STOP !!??

                                      wäre es trotzdem noch möglich dann einzelne Tabellen zu lassen oder wird dann alles komplett umgestellt .

                                      Da ich viele einzelne Zustände noch habe , außer diesem Zustand VIS Error Warn usw. :

                                      z.B.:

                                      1.JPG
                                      2JPG.JPG
                                      3.JPG

                                      sigi234 Mic 2 Replies Last reply Reply Quote 0
                                      • Mic
                                        Mic Developer @sigi234 last edited by

                                        @sigi234 sagte in [Vorlage] JS: Log-Datei aufbereiten für VIS:

                                        Übrigens ist debug nicht mehr da?

                                        Das sind im Script auch alles nur Beispiele, kannst auch andere Log-Level wie "silly", "debug", usw. darstellen. Hier für Debug:

                                          {
                                            id:             'debug',
                                            filter_all:     [' - debug: ', ''],
                                            filter_any:     [''],
                                            blacklist:      ['', '', ''],
                                            clean:          ['', '', ''],
                                            merge:          true,
                                            sortDescending: true,
                                            jsonColumns:    ['date','level','source','msg'],
                                            jsonDateFormat: 'dd.mm. hh:mm',
                                            jsonLogLength:  100,
                                            jsonMaxLines:   60,
                                            jsonCssToLevel: true,
                                          },
                                        
                                        1 Reply Last reply Reply Quote 1
                                        • sigi234
                                          sigi234 Forum Testing Most Active @Glasfaser last edited by

                                          @Glasfaser sagte in [Vorlage] JS: Log-Datei aufbereiten für VIS:

                                          wäre es trotzdem noch möglich dann einzelne Tabellen zu lassen oder wird dann alles komplett umgestellt .

                                          Ja bitte unbedingt so belassen und die Änderung als Option?

                                          1 Reply Last reply Reply Quote 1
                                          • sigi234
                                            sigi234 Forum Testing Most Active @Mic last edited by

                                            @Mic sagte in [Vorlage] JS: Log-Datei aufbereiten für VIS:

                                            Was sonst noch?

                                            Eine Option für lösche ALLE Logs?

                                            Mic Glasfaser 2 Replies Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            492
                                            Online

                                            31.8k
                                            Users

                                            80.0k
                                            Topics

                                            1.3m
                                            Posts

                                            60
                                            617
                                            121278
                                            Loading More Posts
                                            • Oldest to Newest
                                            • Newest to Oldest
                                            • Most Votes
                                            Reply
                                            • Reply as topic
                                            Log in to reply
                                            Community
                                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                            The ioBroker Community 2014-2023
                                            logo