aboutsummaryrefslogtreecommitdiffstats
path: root/ethlog
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2014-10-14 20:35:54 +0800
committerFelix Lange <fjl@twurst.com>2014-10-17 23:20:44 +0800
commit45d1052229f5390d76e912f15e17240a0eddc7b9 (patch)
treed0bab0b9b0869cecb24753fe7e3320da38607c78 /ethlog
parentd5a7ba1626b9c7bbc5733a44fbda2ed50070c1b9 (diff)
downloadgo-tangerine-45d1052229f5390d76e912f15e17240a0eddc7b9.tar.gz
go-tangerine-45d1052229f5390d76e912f15e17240a0eddc7b9.tar.zst
go-tangerine-45d1052229f5390d76e912f15e17240a0eddc7b9.zip
ethlog: fix StdLogSystem data race on level
Diffstat (limited to 'ethlog')
-rw-r--r--ethlog/loggers.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/ethlog/loggers.go b/ethlog/loggers.go
index 34561853a..edf77bda1 100644
--- a/ethlog/loggers.go
+++ b/ethlog/loggers.go
@@ -6,6 +6,7 @@ import (
"log"
"os"
"sync"
+ "sync/atomic"
)
type LogSystem interface {
@@ -198,7 +199,7 @@ func (logger *Logger) Fatalf(format string, v ...interface{}) {
type StdLogSystem struct {
logger *log.Logger
- level LogLevel
+ level uint32
}
func (t *StdLogSystem) Println(v ...interface{}) {
@@ -210,14 +211,14 @@ func (t *StdLogSystem) Printf(format string, v ...interface{}) {
}
func (t *StdLogSystem) SetLogLevel(i LogLevel) {
- t.level = i
+ atomic.StoreUint32(&t.level, uint32(i))
}
func (t *StdLogSystem) GetLogLevel() LogLevel {
- return t.level
+ return LogLevel(atomic.LoadUint32(&t.level))
}
func NewStdLogSystem(writer io.Writer, flags int, level LogLevel) *StdLogSystem {
logger := log.New(writer, "", flags)
- return &StdLogSystem{logger, level}
+ return &StdLogSystem{logger, uint32(level)}
}