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

FEAT: support custom fields and log file cutting #3

Merged
merged 4 commits into from
May 18, 2023
Merged

FEAT: support custom fields and log file cutting #3

merged 4 commits into from
May 18, 2023

Conversation

Yaocool
Copy link
Contributor

@Yaocool Yaocool commented May 18, 2023

No description provided.

@sfpprxy
Copy link
Collaborator

sfpprxy commented May 18, 2023

log.Default().WithFilename("app.log").WithLevel(log.DebugLevel).WithFields([]zap.Field{
		{
			Key:    "xx_key",
			Type:   zapcore.StringType,
			String: "filed_value",
		},
		{
			Key:    "LocalTime",
			Type:   zapcore.StringType,
			String: time.Now().In(time.Local).Format("2006-01-02 15:04:05.000"),
		},
	}).Init()

可以考虑进步一封装 WithFields 并提供类似 WithHumanTime 这样的 API,以更符合这个库的定位:no option zap wrapper,让调用方更容易的去达到期望的默认效果

log.Default().WithFilename("app.log").WithLevel(log.DebugLevel).WithHumanTime().Local().Init()

@sfpprxy sfpprxy merged commit 0b765ac into xops-infra:master May 18, 2023
@sfpprxy sfpprxy mentioned this pull request May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants