Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging: Add time_local option to use local time instead of UTC #5108

Merged
merged 1 commit into from Oct 5, 2022

Conversation

francislavoie
Copy link
Member

Closes #5019

Adds a new time_local flag for encoders which logs in local time.

Example config:

:8881 {
	log {
		format console {
			time_format wall_milli
			time_local
		}
	}
}

Before:

2022/10/02 20:23:38.548	INFO	tls	finished cleaning storage units
2022/10/02 20:23:39.603	info	http.log.access.log0	handled request	{"request": {"remote_ip": "127.0.0.1", "remote_port": "45332", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8881", "uri": "/", "headers": {"Accept": ["*/*"], "User-Agent": ["curl/7.74.0"]}}, "user_id": "", "duration": 0.000001415, "size": 0, "status": 0, "resp_headers": {"Server": ["Caddy"]}}

After:

2022/10/02 20:23:27.753	INFO	tls	finished cleaning storage units
2022/10/02 16:23:29.178	info	http.log.access.log0	handled request	{"request": {"remote_ip": "127.0.0.1", "remote_port": "45326", "proto": "HTTP/1.1", "method": "GET", "host": "localhost:8881", "uri": "/", "headers": {"User-Agent": ["curl/7.74.0"], "Accept": ["*/*"]}}, "user_id": "", "duration": 0.000001377, "size": 0, "status": 0, "resp_headers": {"Server": ["Caddy"]}}

As you can see the default logger still uses UTC, but the configured access logger uses local time (for me, -4h).

@francislavoie francislavoie added the feature ⚙️ New feature or request label Oct 2, 2022
@francislavoie francislavoie added this to the v2.6.2 milestone Oct 2, 2022
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, that was easier than I thought!

Thanks for the patch. If you have a chance do you want to resolve the conflict and then feel free to merge this in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ⚙️ New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

logfile can not output localtime
2 participants