newsnowlabs / docker-ingress-routing-daemon

Docker swarm daemon that modifies ingress mesh routing to expose true client IPs to service containers
MIT License
161 stars 31 forks source link

feat: Adapt log format if journald is detected #36

Closed riton closed 5 months ago

riton commented 5 months ago

Motivation

When the script is launched using systemd and Journald, system logs already has informations such as hostname, pid or datetime.

Example

Log before the patch

Jan 16 17:54:43 THE_HOSTNAME docker-ingress-routing-daemon[1623120]: 2024-01-16.17:54:43.099254|THE_HOSTNAME|1623097| Docker Ingress Routing Daemon 4.1.1 starting ...                                                                    
Jan 16 17:54:43 THE_HOSTNAME docker-ingress-routing-daemon[1623135]: 2024-01-16.17:54:43.123564|THE_HOSTNAME|1623097| Detecting ingress network and node IP:                                                                              
Jan 16 17:54:43 THE_HOSTNAME docker-ingress-routing-daemon[1623139]: 2024-01-16.17:54:43.127176|THE_HOSTNAME|1623097| - Ingress subnet: 10.0.0.0/24                                                                                       
Jan 16 17:54:43 THE_HOSTNAME docker-ingress-routing-daemon[1623143]: 2024-01-16.17:54:43.130406|THE_HOSTNAME|1623097| - This node's IP: 10.0.0.2 

Log after the patch

Jan 16 18:08:42 THE_HOSTNAME docker-ingress-routing-daemon[1623972]: Docker Ingress Routing Daemon 4.1.1 starting ...                                                                
Jan 16 18:08:52 THE_HOSTNAME docker-ingress-routing-daemon[1623972]: Detecting ingress network and node IP:                                                                                                                              
Jan 16 18:08:52 THE_HOSTNAME docker-ingress-routing-daemon[1623972]: - Ingress subnet: 10.0.0.0/24                                                                                                                                       
Jan 16 18:08:52 THE_HOSTNAME docker-ingress-routing-daemon[1623972]: - This node's IP: 10.0.0.2
struanb commented 5 months ago

@riton Thanks for submitting this pull request. This seems like a sensible improvement. I haven't tested it, but you clearly have and as the patch seems uncontroversial I will just merge. Thanks so much again.