aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/log/log.go
diff options
context:
space:
mode:
authorViktor TrĂ³n <viktor.tron@gmail.com>2018-06-22 05:00:43 +0800
committerGitHub <noreply@github.com>2018-06-22 05:00:43 +0800
commiteaff89291ce998ba4bf9b9816ca8a15c8b85f440 (patch)
treec77d7a06627a1a7f578d0fec8e39788e66672e53 /swarm/log/log.go
parentd926bf2c7e3182d694c15829a37a0ca7331cd03c (diff)
parente187711c6545487d4cac3701f0f506bb536234e2 (diff)
downloaddexon-eaff89291ce998ba4bf9b9816ca8a15c8b85f440.tar
dexon-eaff89291ce998ba4bf9b9816ca8a15c8b85f440.tar.gz
dexon-eaff89291ce998ba4bf9b9816ca8a15c8b85f440.tar.bz2
dexon-eaff89291ce998ba4bf9b9816ca8a15c8b85f440.tar.lz
dexon-eaff89291ce998ba4bf9b9816ca8a15c8b85f440.tar.xz
dexon-eaff89291ce998ba4bf9b9816ca8a15c8b85f440.tar.zst
dexon-eaff89291ce998ba4bf9b9816ca8a15c8b85f440.zip
Merge pull request #17041 from ethersphere/swarm-network-rewrite-merge
Swarm POC3 - happy solstice
Diffstat (limited to 'swarm/log/log.go')
-rw-r--r--swarm/log/log.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/swarm/log/log.go b/swarm/log/log.go
new file mode 100644
index 000000000..ce372632e
--- /dev/null
+++ b/swarm/log/log.go
@@ -0,0 +1,48 @@
+package log
+
+import (
+ l "github.com/ethereum/go-ethereum/log"
+ "github.com/ethereum/go-ethereum/metrics"
+)
+
+const (
+ // CallDepth is set to 1 in order to influence to reported line number of
+ // the log message with 1 skipped stack frame of calling l.Output()
+ CallDepth = 1
+)
+
+// Warn is a convenient alias for log.Warn with stats
+func Warn(msg string, ctx ...interface{}) {
+ metrics.GetOrRegisterCounter("warn", nil).Inc(1)
+ l.Output(msg, l.LvlWarn, CallDepth, ctx...)
+}
+
+// Error is a convenient alias for log.Error with stats
+func Error(msg string, ctx ...interface{}) {
+ metrics.GetOrRegisterCounter("error", nil).Inc(1)
+ l.Output(msg, l.LvlError, CallDepth, ctx...)
+}
+
+// Crit is a convenient alias for log.Crit with stats
+func Crit(msg string, ctx ...interface{}) {
+ metrics.GetOrRegisterCounter("crit", nil).Inc(1)
+ l.Output(msg, l.LvlCrit, CallDepth, ctx...)
+}
+
+// Info is a convenient alias for log.Info with stats
+func Info(msg string, ctx ...interface{}) {
+ metrics.GetOrRegisterCounter("info", nil).Inc(1)
+ l.Output(msg, l.LvlInfo, CallDepth, ctx...)
+}
+
+// Debug is a convenient alias for log.Debug with stats
+func Debug(msg string, ctx ...interface{}) {
+ metrics.GetOrRegisterCounter("debug", nil).Inc(1)
+ l.Output(msg, l.LvlDebug, CallDepth, ctx...)
+}
+
+// Trace is a convenient alias for log.Trace with stats
+func Trace(msg string, ctx ...interface{}) {
+ metrics.GetOrRegisterCounter("trace", nil).Inc(1)
+ l.Output(msg, l.LvlTrace, CallDepth, ctx...)
+}