-
Notifications
You must be signed in to change notification settings - Fork 116
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
fix: added mutex around writes to logger struct for concurrent use of many… #269
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mateuszkowalke, thanks for the issue and fix. Just a small change to complete this.
log/logger.go
Outdated
type logger struct { | ||
prefix string | ||
logLevel uint | ||
sync.Mutex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sync.Mutex | |
lock sync.Mutex |
Logger
has no functionality related to Mutex, so embedding (inheriting) is not needed.
log/logger.go
Outdated
} | ||
|
||
func (l *logger) SetLogLevel(logLevel uint) { | ||
l.Lock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l.Lock() | |
l.lock.Lock() |
log/logger.go
Outdated
l.logLevel = logLevel | ||
l.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l.Unlock() | |
l.lock.Unlock() |
log/logger.go
Outdated
} | ||
|
||
func (l *logger) LogLevel() uint { | ||
return l.logLevel | ||
} | ||
|
||
func (l *logger) SetPrefix(prefix string) { | ||
l.Lock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l.Lock() | |
l.lock.Lock() |
log/logger.go
Outdated
l.prefix = prefix | ||
l.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l.Unlock() | |
l.lock.Unlock() |
Codecov Report
@@ Coverage Diff @@
## master #269 +/- ##
==========================================
- Coverage 91.78% 91.64% -0.14%
==========================================
Files 23 23
Lines 1984 1988 +4
==========================================
+ Hits 1821 1822 +1
- Misses 108 111 +3
Partials 55 55
Continue to review full report at Codecov.
|
… clients
Closes #268
Proposed Changes
added mutex around logger struct
Checklist