esphome_syslog icon indicating copy to clipboard operation
esphome_syslog copied to clipboard

This feature is only available with frameworks ['arduino'].

Open dig12345 opened this issue 1 year ago • 9 comments

Any chance we can get this to work with: framework: type: esp-idf

I need that for a different component (secplus_gdo) I believe.

dig12345 avatar Sep 13 '24 03:09 dig12345

Hi,

This has been reported multiple times! You can try PR #17 by @dwmw2, I haven't had an opportunity to test/validate it yet, but it seems to work for him and possibly others.

Sorry for being so absent for this issue, I'll keep this open until something gets merged to fix it.

Thanks

TheStaticTurtle avatar Sep 13 '24 08:09 TheStaticTurtle

Welcome back :)

Now it works fairly much everywhere (even using it on LibreTiny BK72xx devices now) I'm tempted to tidy it up a little and submit it for inclusion in ESPHome. Would you be OK with that? Want to be listed as a CODEOWNER?

dwmw2 avatar Sep 13 '24 08:09 dwmw2

Thanks,

I worked on this a bit a long while ago, I wanted to write a proper syslog client library which would be portable across projects, but it got abandoned due to lack of time.

I just re-read the code, and it seems fine, the IETF format looks correct. I'll try to do some tests tonight/weekend, I don't have direct access to my setup right now.

Cool that it works with LibreTiny but it makes sense now that there is no mention of esp/Arduino in the code.

As for submitting for inclusion in ESPHome, it has already been suggested as a feature request, but that was a while ago. If cleaned-up and up to standards, they might want it (I'll be OK with it, same with being a codeowner)

IMO, here are a few things that need to be done before :

  • Better way of stripping the ANSI control sequences
  • Checking that it stills works when Wi-Fi/Ethernet disconnects / reconnects
  • Update the code to follow ESPHome's codebase standards

Anyway, thanks for the PR, I'll try to build a dev environment in the following days Don't hesitate to ping me if I forget, this has been open for far too long.

TheStaticTurtle avatar Sep 13 '24 10:09 TheStaticTurtle

Yeah, I have been thinking of fixing the escape code stuff; some of them do still escape.

It does work when WiFi reconnects, but perhaps only if the IP address doesn't change. I'll see if I can test that.

I also had DNS support on my TODO list before submitting it.

dwmw2 avatar Sep 13 '24 10:09 dwmw2

Thank you for this! I was finally able to capture logs. I used the following config:

external_components:
  - source:
      url: https://github.com/dwmw2/esphome_syslog.git
      type: git
      ref: esp-ipv6-support
    components: [syslog]

syslog:
    ip_address: "192.168.4.254"
    port: 514
    strip_colors: true

Some interesting things:

  1. I am still seeing some color tags eg: Sep 15 17:05:54 grgdo1 esp-idf [D][esp-idf:000]#033[1;31m[gdo_main_task]#033[0;36m: #033[0;32mI (8286) gdolib: cmd=308 (PAIRED_DEVICES) byte2=03 byte1=00 nibble=1#033[0m S (I see you noted that above)
  2. Interesting that it refuses to send to a syslog server on another subnet, this may be an esphome security limitation, dunno... I ended up creating a port forward on the local vlan router over to the correct server but that was took a while to realize why it wasn't sending any syslog packets.
  3. What log level does it filter on? I have
logger:
 level: VERY_VERBOSE

but that seems to only apply to the logs presented inside ESPhome not the syslog ones.

Anyway much appreciate the work on this, I've been wanting log capture for a long time and this works!

dig12345 avatar Sep 16 '24 13:09 dig12345

  1. Yes, we talked about better filtering of escape codes but I haven't done anything about it yet.
  2. That's odd; I don't have that problem. My syslog server is on a different subnet (both IPv6 and Legacy IP), and both work. Are you sure it isn't falling foul of firewall rules?
  3. I haven't changed anything about log levels. Not intentionally at least.

I suspect this version may break on rp2040 and esp8266 — we actually do need to use the Arduino UDP there. See discussion in https://github.com/esphome/esphome/pull/4969

dwmw2 avatar Sep 16 '24 14:09 dwmw2

  1. Yes, we talked about better filtering of escape codes but I haven't done anything about it yet.
  2. That's odd; I don't have that problem. My syslog server is on a different subnet (both IPv6 and Legacy IP), and both work. Are you sure it isn't falling foul of firewall rules?
  3. I haven't changed anything about log levels. Not intentionally at least.

I suspect this version may break on rp2040 and esp8266 — we actually do need to use the Arduino UDP there. See discussion in esphome/esphome#4969

Thanks for the PR. Works fine here on esp_idf across subnets.

mateuszdrab avatar Jan 07 '25 18:01 mateuszdrab

Trying to catch up on this, is that PR ready to be merged or are there outstanding issues?

rct avatar Feb 22 '25 19:02 rct

I think it needs to be #ifdeffed for esp8266 Arduino and other platforms which were created before 1995 when IPv6 was standardised, rather than ripping out the Arduino UDP version completely and replacing it

dwmw2 avatar Feb 22 '25 20:02 dwmw2