diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-21 21:52:42 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-21 21:52:42 +0800 |
commit | a7ad9c309bf72a9f2b4f12001034e1842ca55319 (patch) | |
tree | fa573f69742e3e7cf9b2a8d124a27c9d4c8d3c2b /logger/logsystem.go | |
parent | ce862ee7589a0780cebc8a7bb1cf6a75193d55a0 (diff) | |
parent | 38c7c589e4a1b08baaab5b81de6aca7fa853d284 (diff) | |
download | dexon-a7ad9c309bf72a9f2b4f12001034e1842ca55319.tar dexon-a7ad9c309bf72a9f2b4f12001034e1842ca55319.tar.gz dexon-a7ad9c309bf72a9f2b4f12001034e1842ca55319.tar.bz2 dexon-a7ad9c309bf72a9f2b4f12001034e1842ca55319.tar.lz dexon-a7ad9c309bf72a9f2b4f12001034e1842ca55319.tar.xz dexon-a7ad9c309bf72a9f2b4f12001034e1842ca55319.tar.zst dexon-a7ad9c309bf72a9f2b4f12001034e1842ca55319.zip |
Merge branch 'develop' into conversion
Diffstat (limited to 'logger/logsystem.go')
-rw-r--r-- | logger/logsystem.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/logger/logsystem.go b/logger/logsystem.go index 8458b938f..1318a9f96 100644 --- a/logger/logsystem.go +++ b/logger/logsystem.go @@ -61,3 +61,27 @@ func (t *rawLogSystem) SetLogLevel(i LogLevel) { func (t *rawLogSystem) 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 NewJsonLogSystem(writer io.Writer, flags int, level LogLevel) LogSystem { + logger := log.New(writer, "", 0) + return &jsonLogSystem{logger, uint32(level)} +} + +type jsonLogSystem struct { + logger *log.Logger + level uint32 +} + +func (t *jsonLogSystem) LogPrint(level LogLevel, msg string) { + t.logger.Print(msg) +} + +func (t *jsonLogSystem) SetLogLevel(i LogLevel) { + atomic.StoreUint32(&t.level, uint32(i)) +} + +func (t *jsonLogSystem) GetLogLevel() LogLevel { + return LogLevel(atomic.LoadUint32(&t.level)) +} |