aboutsummaryrefslogtreecommitdiffstats
path: root/logger/logsystem.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-01-22 00:16:15 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-01-22 00:16:15 +0800
commitacdc19d1b7b25d6ebd8457f423659f3d112a4a75 (patch)
tree3c3d66a06567682bbb31692d9b27d983e69c684d /logger/logsystem.go
parent7f9c3354872e6fcc63c37abddb184e3e58790bc3 (diff)
downloaddexon-acdc19d1b7b25d6ebd8457f423659f3d112a4a75.tar.gz
dexon-acdc19d1b7b25d6ebd8457f423659f3d112a4a75.tar.zst
dexon-acdc19d1b7b25d6ebd8457f423659f3d112a4a75.zip
Add rawLogSystem
Diffstat (limited to 'logger/logsystem.go')
-rw-r--r--logger/logsystem.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/logger/logsystem.go b/logger/logsystem.go
index f154773ae..3601e926c 100644
--- a/logger/logsystem.go
+++ b/logger/logsystem.go
@@ -29,3 +29,27 @@ func (t *stdLogSystem) SetLogLevel(i LogLevel) {
func (t *stdLogSystem) GetLogLevel() LogLevel {
return LogLevel(atomic.LoadUint32(&t.level))
}
+
+// NewRawLogSystem creates a LogSystem that prints to the given writer without
+// adding extra information. Suitable for preformatted output
+func NewRawLogSystem(writer io.Writer, flags int, level LogLevel) LogSystem {
+ logger := log.New(writer, "", 0)
+ return &rawLogSystem{logger, uint32(level)}
+}
+
+type rawLogSystem struct {
+ logger *log.Logger
+ level uint32
+}
+
+func (t *rawLogSystem) LogPrint(level LogLevel, msg string) {
+ t.logger.Print(msg)
+}
+
+func (t *rawLogSystem) SetLogLevel(i LogLevel) {
+ atomic.StoreUint32(&t.level, uint32(i))
+}
+
+func (t *rawLogSystem) GetLogLevel() LogLevel {
+ return LogLevel(atomic.LoadUint32(&t.level))
+}