mdlayher / consrv

Command consrv is a SSH to serial console bridge server, originally designed for deployment on gokrazy.org devices. Apache 2.0 Licensed.
Other
136 stars 4 forks source link

add logtostdout option to copy serial to stdout #5

Closed stapelberg closed 2 years ago

stapelberg commented 2 years ago

This is handy with gokrazy’s remote syslog support:

https://gokrazy.org/userguide/remotesyslog/

…and the gokrazy syslog daemon:

https://github.com/gokrazy/syslogd

fixes https://github.com/mdlayher/consrv/issues/2

mdlayher commented 2 years ago

Seems totally reasonable, but thinking about this from a multi-device perspective: what could we do to multiplex the output from several devices to stdout? Should we prefix the messages somehow and ensure that lines are cleanly flushed so that they can be grepped/filtered out later in a logging system?

stapelberg commented 2 years ago

Seems totally reasonable, but thinking about this from a multi-device perspective: what could we do to multiplex the output from several devices to stdout?

I think the simplest is adding a mutex that’s acquired by all copy-to-stdout goroutines before writing to stdout.

Should we prefix the messages somehow and ensure that lines are cleanly flushed so that they can be grepped/filtered out later in a logging system?

Prefixing with device.Name sounds reasonable to me.

We could probably only add the prefix when more than 1 device is configured. What do you think?

mdlayher commented 2 years ago

SGTM, thank you!

stapelberg commented 2 years ago

Done! PTAL