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…
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
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 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
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).
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.
Looking great Arie!
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;)