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

log: use atomic types #27763

Merged
merged 4 commits into from
Aug 4, 2023
Merged

log: use atomic types #27763

merged 4 commits into from
Aug 4, 2023

Conversation

ucwong
Copy link
Contributor

@ucwong ucwong commented Jul 24, 2023

No description provided.

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM

@holiman holiman changed the title log: atomic types used in log log: use atomic types Jul 27, 2023
log/format.go Outdated
}
}

// locationEnabled is an atomic flag controlling whether the terminal formatter
// should append the log locations too when printing entries.
var locationEnabled uint32
var locationEnabled atomic.Uint32
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be an atomic.Bool, really. It's a small enough change that we might just as well fix it in this PR while we're at it, IMO,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done

override uint32 // Flag whether overrides are used, atomically accessible
backtrace uint32 // Flag whether backtrace location is set
level atomic.Uint32 // Current log level, atomically accessible
override atomic.Uint32 // Flag whether overrides are used, atomically accessible
Copy link
Contributor

Choose a reason for hiding this comment

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

This could also be a boolean. Instead of setting it to len(filter), we would set it to len(filter) != 0

return h.origin.Log(r)
}
// If no local overrides are present, fast track skipping
if atomic.LoadUint32(&h.override) == 0 {
if h.override.Load() {
Copy link
Contributor

Choose a reason for hiding this comment

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

It needs to be either
h.override.Store(len(filter) != 0) and check if !h.override.Load() {
or
h.override.Store(len(filter) == 0) and check if h.override.Load() {

backtrace uint32 // Flag whether backtrace location is set
level atomic.Uint32 // Current log level, atomically accessible
override atomic.Bool // Flag whether overrides are used, atomically accessible
backtrace atomic.Uint32 // Flag whether backtrace location is set
Copy link
Contributor

Choose a reason for hiding this comment

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

hm, backtrace also looks very boolean, in it's usage, to me :)

@ucwong ucwong force-pushed the at-log branch 2 times, most recently from e0b71c0 to 0d9e6fd Compare August 1, 2023 13:36
Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM

@fjl fjl merged commit 5c30541 into ethereum:master Aug 4, 2023
1 check passed
@fjl fjl added this to the 1.12.1 milestone Aug 4, 2023
devopsbo3 pushed a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 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.

4 participants