[APP][Pro] Simple (Sys) LOG - Use this app for Simple (Sys) Logging

Hi @Arie_J_Godschalk,

When I try to export to a CSV or Excel file the Simple (Sys) LOG app crashes.

I’m running on app version v3.0.33.

Best Regards, Hugo

Hi @Arie_J_Godschalk ,

Is it possible to add some extra functionality to the Simple (Sys) LOG app?
I use the search on messages very often, which works very great.

It would be very nice if it would also be possible to use some “AND, OR” statements in the search field too.
image
Filtering on the right message results becomes even better/easier then.

Many thanks!

Best Regards, Hugo

How many log entries do exist when exporting? I think it should be below 10,000 entries

Ah great! That made my csv conversion work. The ‘logs’ part was messing things up but I couldn’t find a fix

// define url
const url = "http://192.168.1.223/api/app/nl.nielsdeklerk.log/";
// get data
let data1 = await fetch(url);
// make it json
let dataJson = await data1.json();
const table = dataJson.logs;
//console.log(table);

const replacer = (key, value) => value === null ? '-' : value // specify how you want to handle null values here
const header = Object.keys(table[0])
const csv = [
  header.join(','), // header row first
  ...table.map(row => header.map(fieldName => JSON.stringify(row[fieldName], replacer)).join(','))
].join('\r\n')

console.log(csv);

For me even more convenience: push a button and have it mailed to me:

1 Like

Hi Peter,

Far beyond the 10k entries (31.695). It would be possible that this is an issue. But I do not prefer to delete my messages now. Hopefully, there is a solution to still export them.

Here’s my attempt at creating a html page to present the syslog API in a readable way.

Problem still left is that I cannot seem to get variable loaded with latest data from the Homey. For now there’s a constant set with a hardcoded JSON array.

I’m stuck basically.

So, if someone more familiar with HTML coding could get this going I would be happy.
:innocent:

<!DOCTYPE html>
<html>
<head>
    <style>
        table, th, td 
        {
            border: solid 1px #ddd;
            border-collapse: collapse;
            padding: 2px 3px;
            text-align: center;
        }
        th { 
            font-weight:bold;
        }
    </style>
</head>
<body>
    <input type='button' onclick='tableFromJson()' value='Create Table from JSON data' />
    <p id="showData"></p>

</body>

<script>
  let tableFromJson = () => {
    // the json data.
    const response = [
      {"logs":[{"id":"2023/07/25$26","timestamp":"2023-07-25T13:03:42.752Z","severity":5,"facility":17,"app":"Contact","message":"Entrance Contact alarm  from Ytterdörr  "},{"id":"2023/07/25$25","timestamp":"2023-07-25T10:40:23.076Z","severity":6,"facility":1,"app":"Garage","message":"Garage2 stängdes efter 37 sec."},{"id":"2023/07/25$24","timestamp":"2023-07-25T10:38:44.489Z","severity":5,"facility":1,"app":"Garage","message":"Garage2 styrd Remotely."},{"id":"2023/07/25$23","timestamp":"2023-07-25T10:36:34.542Z","severity":6,"facility":1,"app":"Garage","message":"Garage2 stängdes efter 10 sec."},{"id":"2023/07/25$22","timestamp":"2023-07-25T10:36:34.527Z","severity":5,"facility":1,"app":"Garage","message":"Garage2 styrd Remotely."},{"id":"2023/07/25$21","timestamp":"2023-07-25T10:36:24.233Z","severity":5,"facility":1,"app":"Garage","message":"Garage2 styrd Remotely."},{"id":"2023/07/25$20","timestamp":"2023-07-25T10:35:47.249Z","severity":5,"facility":1,"app":"Garage","message":"Garage2 styrd Remotely."},{"id":"2023/07/25$19","timestamp":"2023-07-25T10:34:35.300Z","severity":5,"facility":1,"app":"Garage","message":"Garage2 styrd Remotely."}],"count":8}
    ]

//const url = "http://192.168.1.223/api/app/nl.nielsdeklerk.log/";
//let data= await fetch(url);

//response = await data.json();

//var myBooks = response.logs;

const myBooks = response[0].logs;

    // Extract value from table header. 

    let col = [];
    for (let i = 0; i < myBooks.length; i++) {
      for (let key in myBooks[i]) {
        if (col.indexOf(key) === -1) {
          col.push(key);
        }
      }
    }

    // Create table.
    const table = document.createElement("table");

    // Create table header row using the extracted headers above.
    let tr = table.insertRow(-1);                   // table row.

    for (let i = 0; i < col.length; i++) {
      let th = document.createElement("th");      // table header.
      th.innerHTML = col[i];
      tr.appendChild(th);
    }

    // add json data to the table as rows.
    for (let i = 0; i < myBooks.length; i++) {

      tr = table.insertRow(-1);

      for (let j = 0; j < col.length; j++) {
        let tabCell = tr.insertCell(-1);
        tabCell.innerHTML = myBooks[i][col[j]];
      }
    }

    // Now, add the newly created table with json data, to a container.
    const divShowData = document.getElementById('showData');
    divShowData.innerHTML = "";
    divShowData.appendChild(table);

  }
</script>
</html>

Hmmmm I recall having a similar problem, Arie asked to clear up the logs and keep 2 days or 1 day (back then the number of lines were not available). After that, the export succeeded.
My guess is Homey memory system can’t handle that amount of data.

Maybe Arie can make exporting a selection possible one day, while I can imagine you don’t want to lose your logs, but want to shrink the log on Homey.
Like, “export today’s logs”, or export “yesterdays logs” etcetera.

Yeah that would be very nice. It would also very helpful to have an option to delete specific message based on part of the messages text for example (search/delete based on specific advance criteria in flows). @Arie_J_Godschalk

1 Like

Sure, please create a feature ticket on the support site. Thanks!

1 Like

Which Homey do you have? Hp2023? Or previous model?

Where can I find the support site for Simple (Sys) Log?

HP2023 indeed.

The link is in the top posts of my topics:
https://bitbucket.org/QlusterIT/nl.qluster-it.simplelog/issues?status=new&status=open

Well, on the HP2023, i have been able to generate excel files with over 150.000 lines, so that should not be the issue.
However, before i can fix this, i first am waiting for the HP2023 to function more properly (then the last time i migrated), and i am currently updating the Device Capabilities app to the new homey-api.
This takes up all my homey-time atm, and next week i have another holiday.

So, yes i will fix this, but i don’t expect to be able to fix it within the next 1,5 to 2 weeks. Sorry.

2 Likes

No problem, I completely understand. We are very happy with your great apps and all the work you put into it (very appreciated). Hope you have a great holiday!

2 Likes

HTML page ready!

Here you can check Syslog on the fly (while at home).
Just change the Homey IP address in the URL…

Save this code to a HTML file and save on eg. your Home screen on you phone.

<!DOCTYPE html>
<html>
<head>
    <style>
        table, th, td 
        {
            border: solid 1px #ddd;
            border-collapse: collapse;
            padding: 2px 3px;
            text-align: left;
        }
        th { 
            font-weight:bold;
        }
    </style>
</head>
<body>
    
    <p id="showData"></p>

</body>

<script>

    // the json data.

const url = "http://192.168.1.223/api/app/nl.nielsdeklerk.log/";

async function FetchData() {
  const response = await fetch(url);
  const data = await response.text();
  const string = "["+data+"]";
  const myJSON = JSON.parse(string);
  const JSONtable = myJSON[0].logs;

  response.ok;     // => false
  response.status; // => 404

  return JSONtable;
}

FetchData().then(JSONtable => {
  JSONtable; // => 'Page not found'

    // Extract value from table header. 

    let col = [];
    for (let i = 0; i < JSONtable.length; i++) {
      for (let key in JSONtable[i]) {
        if (col.indexOf(key) === -1) {
          col.push(key);
        }
      }
    }

    // Create table.
    const table = document.createElement("table");

    // Create table header row using the extracted headers above.
    let tr = table.insertRow(-1);                   // table row.

    for (let i = 0; i < col.length; i++) {
      let th = document.createElement("th");      // table header.
      th.innerHTML = col[i];
      tr.appendChild(th);
    }

    // add json data to the table as rows.
    for (let i = 0; i < JSONtable.length; i++) {

      tr = table.insertRow(-1);

      for (let j = 0; j < col.length; j++) {
        let tabCell = tr.insertCell(-1);
        tabCell.innerHTML = JSONtable[i][col[j]];
      }
    }

    // Now, add the newly created table with json data, to a container.
    const divShowData = document.getElementById('showData');
    divShowData.innerHTML = "";
    divShowData.appendChild(table);

	});
  

</script>
</html>
3 Likes

For some time now I have been struggling with exporting my simple log files to my Nas.
For some time now I have let it alone but today I thought, let’s have a look again if it will work but unfortunately it stil doesn’t work for me.

The Simple log app just crashes when I run my flow.
Tested with all available options and with all of them it does crash. The export card works just fine and I see a log file in my destination folder. That file does contain all kind of weird text but that must be because of the card that causes the crash?



This is what is inside the csv file.

u«Z
Wš­çZ–Yh‚§Ö­j
躔¢š™^.ˆj׶Óm¾×o¶õ==ßÍôۏYu«Zm§djg«ëGZµí´ÛoµÛí½OOw÷}µïf
u«Z
Wš­çZ–Yh‚§Ö­j
躔¢š™^.ˆj׶Óm¾×o¶õ==ßÍôۏYu«Zm§djg«ëGZµí´ÛoµÛí½OOw÷}µïf

b99c5d1d-e935-42c7-a4b6-905fc2a64385

Thanks.

Wow very nice!
Somehow I the ‘message’ column isn’t shown, do you have any ideas? Thanks!
EDIT:
text-align: left” showed my messages :crazy_face: There probable was a very long one somewhere, so when the columns alignments are centered, I didn’t see any at first

<html>
<head>
    <style>
        table, th, td
        {
            border: solid 1px #ddd;
            border-collapse: collapse;
            padding: 2px 3px;
            font-family: verdana;
            text-align: left;
         }
            tr:nth-child(even) {
            background-color: #D6EEEE;
            }
            tr:hover {
            background-color: #D6EEEE;
            }
        th {
            font-weight: bold;
            font-family: verdana;
            text-align: left;
        }
    </style>
</head>
1 Like

Flip the phone to landscape?

1 Like

On a laptop here :wink: but I found the ‘issue’