aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-06-14 21:44:13 +0800
committerobscuren <geffobscura@gmail.com>2014-06-14 21:44:13 +0800
commit6d52da58d9337b786a0c869974daa91ce0e34a98 (patch)
tree3efe1b3af6cad5bcd09d0868df64d2ad633eaab8 /ethutil
parent63883bf27d8b87f601e1603e9024a279b91bffb7 (diff)
downloaddexon-6d52da58d9337b786a0c869974daa91ce0e34a98.tar.gz
dexon-6d52da58d9337b786a0c869974daa91ce0e34a98.tar.zst
dexon-6d52da58d9337b786a0c869974daa91ce0e34a98.zip
Logging mechanism
Diffstat (limited to 'ethutil')
-rw-r--r--ethutil/config.go27
1 files changed, 26 insertions, 1 deletions
diff --git a/ethutil/config.go b/ethutil/config.go
index f935e8f75..90037df87 100644
--- a/ethutil/config.go
+++ b/ethutil/config.go
@@ -143,12 +143,17 @@ func NewLogger(flag LoggerType, level int) *Logger {
return &Logger{logSys: loggers, logLevel: level}
}
+func (self *Logger) SetLevel(level int) {
+ self.logLevel = level
+}
+
func (log *Logger) AddLogSystem(logger LogSystem) {
log.logSys = append(log.logSys, logger)
}
const (
- LogLevelDebug = iota
+ LogLevelSystem = iota
+ LogLevelDebug
LogLevelInfo
)
@@ -204,6 +209,26 @@ func (log *Logger) Fatal(v ...interface{}) {
os.Exit(1)
}
+func (log *Logger) Println(level int, v ...interface{}) {
+ if log.logLevel > level {
+ return
+ }
+
+ for _, logger := range log.logSys {
+ logger.Println(v...)
+ }
+}
+
+func (log *Logger) Printf(level int, format string, v ...interface{}) {
+ if log.logLevel > level {
+ return
+ }
+
+ for _, logger := range log.logSys {
+ logger.Printf(format, v...)
+ }
+}
+
type confValue struct {
value string
}