aboutsummaryrefslogtreecommitdiffstats
path: root/ethlog/README.md
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-06-27 01:55:14 +0800
committerobscuren <geffobscura@gmail.com>2014-06-27 01:55:14 +0800
commit9d5a3f013121c319f9cf679d9afc4e40661a0284 (patch)
treef57ecbea40ca0354bb050d70a10851669412a581 /ethlog/README.md
parent3f1f8438ed8bf7b63ea5172090a5c7025cb093f0 (diff)
parenta98e6a262a21ff08c28495bab5180a1c15826d40 (diff)
downloadgo-tangerine-9d5a3f013121c319f9cf679d9afc4e40661a0284.tar
go-tangerine-9d5a3f013121c319f9cf679d9afc4e40661a0284.tar.gz
go-tangerine-9d5a3f013121c319f9cf679d9afc4e40661a0284.tar.bz2
go-tangerine-9d5a3f013121c319f9cf679d9afc4e40661a0284.tar.lz
go-tangerine-9d5a3f013121c319f9cf679d9afc4e40661a0284.tar.xz
go-tangerine-9d5a3f013121c319f9cf679d9afc4e40661a0284.tar.zst
go-tangerine-9d5a3f013121c319f9cf679d9afc4e40661a0284.zip
Merge branch 'release/0.5.15'
Diffstat (limited to 'ethlog/README.md')
-rw-r--r--ethlog/README.md62
1 files changed, 62 insertions, 0 deletions
diff --git a/ethlog/README.md b/ethlog/README.md
new file mode 100644
index 000000000..d9b69e106
--- /dev/null
+++ b/ethlog/README.md
@@ -0,0 +1,62 @@
+## Features
+
+- packages use tagged logger sending log messages to shared (process-wide) logging engine
+- log writers (interface ethlog.LogSystem) can be added to the logging engine by wrappers/guis/clients
+- shared logging engine dispatching to multiple log systems
+- log level can be set separately per log system
+- async logging thread: logging IO does not block main thread
+- log messages are synchronously stringified to avoid incorrectly logging of changed states
+- log level enum: ethlog.LogLevel: Silence, ErrorLevel, WarnLevel, InfoLevel, DebugLevel, DebugDetailLevel
+
+## Usage
+
+In an ethereum component package:
+
+ import "github.com/ethereum/eth-go/ethlog"
+
+ // package-wide logger using tag
+ var logger = ethlog.NewLogger("TAG")
+
+Logger provides named Printf and Println style methods for all loglevels
+
+ logger.Infoln("this is info") # > [TAG] This is info
+ logger.Infof("this %v is info", object) # > [TAG] This object is info
+
+Ethereum wrappers should register log systems conforming to ethlog.LogSystem
+
+ import "github.com/ethereum/eth-go/ethlog"
+
+ type CustomLogWriter struct {
+ logLevel ethlog.LogLevel
+ }
+
+ func (t *TestLogSystem) SetLogLevel(i LogLevel) {
+ t.level = i
+ }
+
+ func (t *TestLogSystem) GetLogLevel() LogLevel {
+ return t.level
+ }
+
+ func (c *CustomLogWriter) Printf(format string, v...interface{}) {
+ //....
+ }
+
+ func (c *CustomLogWriter) Println(v...interface{}) {
+ //....
+ }
+
+ ethlog.AddLogWriter(&CustomLogWriter{})
+
+ethlog also provides constructors for that wrap io.Writers into a standard logger with a settable level:
+
+ filename := "test.log"
+ file, _ := os.OpenFile(filename, os.O_RDWR|os.O_CREATE, os.ModePerm)
+ fileLogSystem := NewStdLogSystem(file, 0, WarnLevel)
+ AddLogSystem(fileLogSystem)
+ stdOutLogSystem := NewStdLogSystem(os.Stdout, 0, WarnLevel)
+ AddLogSystem(stdOutLogSystem)
+
+
+
+