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

ConsoleWriter: remove fields written within "PartsOrder" so they are not duplicated in output log #383

Merged
merged 1 commit into from Jun 28, 2022

Conversation

adamko147
Copy link
Contributor

close #204

once the field is written into Parts, remove it form evt so it's no longer written to fields

@adamko147 adamko147 changed the title remove fields written into "PartsOrder" remove fields written withing "PartsOrder" so they are not duplicated in output log Dec 4, 2021
@adamko147 adamko147 changed the title remove fields written withing "PartsOrder" so they are not duplicated in output log remove fields written within "PartsOrder" so they are not duplicated in output log Dec 4, 2021
@adamko147 adamko147 changed the title remove fields written within "PartsOrder" so they are not duplicated in output log ConsoleWriter: remove fields written within "PartsOrder" so they are not duplicated in output log Dec 4, 2021
Copy link

@DanMan259 DanMan259 left a comment

Choose a reason for hiding this comment

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

Tested and completes the task intended

@DanMan259
Copy link

Solves issues #446 #424 #128

@rs rs merged commit 2a13872 into rs:master Jun 28, 2022
rs added a commit that referenced this pull request Jul 16, 2022
pablitoc pushed a commit to nxcr-org/zerolog that referenced this pull request Apr 7, 2023
pablitoc pushed a commit to nxcr-org/zerolog that referenced this pull request Apr 7, 2023
@adubkov
Copy link

adubkov commented May 10, 2023

@rs Why this was reverted? The issue is still valid.

@adubkov
Copy link

adubkov commented May 10, 2023

Ok. I guess I found the answer. There is a workaround for it by using a combination of PartsOrder and FieldsExclude:

    log.Logger = log.Output(zerolog.ConsoleWriter{
        Out:        os.Stderr,
        TimeFormat: time.RFC3339,
        PartsOrder: []string{
            zerolog.TimestampFieldName,
            "ctx",
            zerolog.LevelFieldName,
            zerolog.CallerFieldName,
            zerolog.MessageFieldName,
        },
        FieldsExclude: []string{"ctx"},
    })
2023-05-10T09:56:54Z [1] INF Message

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.

Provide a way to exclude fields from ConsoleWriter
4 participants