dinit
dinit copied to clipboard
[Feature Request] Timestamps for service logs
I was wondering if it is possible to add timestamps to logs of services. Would be quite useful for some long running processes, etc.
I think this would be better managed by adding support to logging chain/logging processors. This way, the timestamp and log rotate programs in projects like busybox, runit and others could be reused. This can even sort-of be done already with FIFO trickery, but official support (and having the Dinit process keep the pipe file descriptors open, for safety) would be nice.
I understand being modular isn't as much of a priority to dinit as it is to the projects I've mentioned, but it'd be a way to keep it focused on service management.
@XynonWasTaken sure, I'm thinking about this. The reason why it is not trivial is because timestamps should be associated with messages when they are generated, but the time is not reliable at early system startup (before the system time has been set from the hardware clock for example). It might be possible to work around this by recording the monotonic time that messages are generated and then, when the log service starts, assume the system time is correct, and use the delta between the current and recorded monotonic clock times to determine the real time of a message.
In the meantime, perhaps you can configure your log daemon to fill in the times? My old syslogd (from GNU inetutils) does this, it seems. The times aren't necessarily fully accurate since the messages may have been created before the logging daemon started.
@capezotte I think this is about log messages generated by dinit, regarding services, rather than messages generated by services themselves. Incidentally, keeping descriptors between services processes and their loggers only gives the illusion of safety: if a logger crashes, it may well have already consumed some of the process output without having recorded it in any log file. (It does have some other benefits though).
I think this would be better managed by adding support to logging chain/logging processors
This has now been implemented.
I think I'll not implement this after all. It's non-trivial in terms of how complex it is to do (see explanation above) and there's really no reason why the logging daemon can't add timestamps to syslog messages that come in without a timestamp; the implementations I've tried actually do so.