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

I have tested the flow connection and found that the UDP transport works but for TCP I still get the error message: “Invalid frame header”.

UDP:

[2023-03-14T19:20:17.290251] Incoming log entry; input='<134>Mar 14 20:20:16 homey-63c568c787e41c0b8ba0db6a HP2023 via Syslog-Client\x0a', msg='0x7fd777829000', rcptid='0'
[2023-03-14T19:20:41.993704] Outgoing message; message='<134>1 2023-03-14T20:20:16+00:00 homey-63c568c787e41c0b8ba0db6a HP2023 - - - via Syslog-Client\x0a'

TCP:

[2023-03-14T19:22:49.988131] Invalid frame header; header=''

My TestMessage :stuck_out_tongue_winking_eye::

image

1 Like

Okay, can you perhaps create a ticket for it.
I’ll look into it as soon as i am able.

Ok, Posted…

1 Like

Hi Arie,

Have you already adapted the API so that you can send the severity, facility, etc.?

Chris

Well, No, not yet specificly.
But i did, just now, added the aditional properties to the existing PUT /addlog/
Also just updated the readme:

- Add log data:
  PUT /api/app/nl.nielsdeklerk.log/addlog/
  Content-Type: application/json
  {"log": "Test 1,2,3", "group": "TEST", "severity" : 6, "facility": 5, "timestamp":new Date() }

Its in test now.

I know there might be need for a more specific, better looking, more confirm the new model - api call, but i first wanna test what is handy in that way.

I’ve already thought about separating my code from myHomey library and publishing the whole thing in a separate package. Then it would be easy for the individual developers to use the interface/app in their code…

But first, the whole thing should work for me.

Which one? What do you mean?
A syslog server?

I mean a development interface (middleware) with a standardized API that internally calls SimpleLogApp and passes the logs (including syslog, of course).

This is what my API looks like at the moment, not brilliant yet but a start:

 async onInit() {
    // myHomey Logger
    this.#simpleLog = SimpleLogApp.getInstance(this)
      .on('connect', () => this.#simpleLog.connect())
      .on('disconnect', () => this.#simpleLog.disconnect());

    await this.#simpleLog.connect()
      .catch((err) => this.error(`onInit() > simpleLog > ${err}`));
  }

  // myHomey logger

  error(msg) {
    if (this.#simpleLog && this.#simpleLog.isConnected()) {
      this.#simpleLog.logError(msg);
    }
    super.error(`[ERROR] ${msg}`);
  }

  info(msg) {
    if (this.#simpleLog && this.#simpleLog.isConnected()) {
      this.#simpleLog.logInfo(msg);
    }
    super.log(`[INFO] ${msg}`);
  }

  debug(msg) {
    // Show the debug message only in debug mode.
    if (process.env.DEBUG === '1') {
      if (this.#simpleLog && this.#simpleLog.isConnected()) {
        this.#simpleLog.logDebug(msg);
      }
      super.log(`[DEBUG] ${msg}`);
    }

Yeah, i am building something simulare in Simple Log, thats why i registered the npm name a few weeks back.
With that, app developers/i, can send developer logs to Simple Log.
Than have that logging do nothing by default.
However, users can specificly change the report-level, hit a button to write the recieved logs back into the real apps real log, so the can send a diagnostic.

That would mean i could now write a lott more logging in my apps, and users can enable and disable it themself (so to not waist resources and have apps grow), and the correct app still gets the needed data for in the diagnostic :slight_smile:

But first have to get it out of the test fase :wink:

Also, not sure if it can help, but i plan on implementing the option to create Syslog servers as devices (so you can have a TCP and a UDP running). Perhaps that can also help.
Should not take a lot of work, since there is a very name-compatable, easy to use, extremly lightweight npm package for that: simple-syslog-server - npm (npmjs.com)

I am a log-maniac !:crazy_face:!

I log already today everything possible (and impossible). I have written/defined a logger flow with the “Advanced Trigger App” and log everything central that happens in my flows. So I only have to make the changes (e.g. for the “new” Simple (Sys) Log App) in one place.

Well perhaps your hyLogger can function as the basis to the npm package ( simplesyslog-npm - npm (npmjs.com) yeah, wrong readme.md, it was just a placeholder :slight_smile:

I would envision a few things tho about a includeable-npm:

  • It would listen/wait for a realtime message from Simple Log before initializing for the first time.
    Keeping it low on resources enless someone wants to use it.
  • Simple Log (through the App Settings) would “activate” logging for a certain app for a certain Severity.
  • Only after recieving such a command should the client-app initialize.
  • the npm-package should contain a (short) backlog (after the above initialisation), so on app restart or when SL is not available, it will keep the log in memory untill it can be handed of to Simple Log.
  • A methode to write logs pushed back from SL into the normal stdout stderr, through its console.log etc, writing the original timestamps and severity etc. That way, a diagnostic can be send through the normal/client app, the “normal” way.
  • By default, logs from client-apps should be a certain Facility, one of the “free” local slots i, on purpose, left of the select lists in SL.

No thanks, I want to use Grafana-Loki with the Syslog server, but the (AIO) stack is still under development.

BDW:
But if you agree, I’ll take a closer look at the Homey-App part, because it doesn’t make sense that we both develop the same thing and I’ve already written part of it (SimpleLogApp Wraper & Interface).

1 Like

It looks like Simple Log, without creating the LOG at ones, stays very stable (even with using the App settings):

On HP2019

Could you share some memory usage with me?
Would love to know how your MB graphs are looking with Simple Log.

Update

Syslog client device has been well tested and some fixes to work better with different syslog-formats.

Also, you can now create a Syslog Server device, to let other devices connect to.
I also added hostname to the Log, which you can just hide if you are not using it.

(@cgHome :slight_smile: )

1 Like

@Peter_Kawa , @Henk_Renting and others:
Here is a script to remove all flowcards (and lines) from flows and advanced flows.

2 Likes

How neat!
Thanks a million!
(and a few :beers: to enjoy your weekend!)
:+1:t2::smiley:

1 Like

Thanks Henk, much appreciated!

1 Like

Looking great Arie! :tada: :tada:
Don’t know if I’m doing something wrong, in 2 standard flows, with an certain app’s action card in “then”, and one in “else”, they’re not getting removed.
I’m on a Homey 2019
Is there anything you need me to test?

This is what the test run in HS returned:
(const reallyExecute = false;)

———————————————————
✅ Script Success
↩️ Returned: undefined
{
  afs: [],
  flows: [
    r {
      __athom_api_type: 'HomeyAPI.ManagerFlow.Flow',
      id: '0b37f1b1-cd6c-426e-9c1c-7a52bd28b075',
      name: 'Regen2: alert open Deur/Raam BuienAlarm Hscript',
      enabled: true,
      folder: 'b92d4d5a-926b-436c-aefc-114e4887784e',
      order: 1669,
      trigger: [Object],
      conditions: [Array],
      actions: [Array],
      broken: false,
      triggerable: true,
      triggerCount: 1154
    },
    r {
      __athom_api_type: 'HomeyAPI.ManagerFlow.Flow',
      id: '71509442-5659-4857-8b12-87aad17b99bd',
      name: 'Huidige Gasmeter stand op VD (Copy)',
      enabled: false,
      folder: '544853bd-119e-40c9-ac20-9f92fa46a0ae',
      order: 2087,
      trigger: [Object],
      conditions: [],
      actions: [Array],
      broken: false,
      triggerable: false,
      triggerCount: 0
    }
  ]
}

Playground console:
(const reallyExecute = true;)
Screenshot from 2023-03-18 00-44-01