Add rawLogSystem

This commit is contained in:
Taylor Gerring 2015-01-21 10:16:15 -06:00
parent 7f9c335487
commit acdc19d1b7
1 changed files with 24 additions and 0 deletions

View File

@ -29,3 +29,27 @@ func (t *stdLogSystem) SetLogLevel(i LogLevel) {
func (t *stdLogSystem) GetLogLevel() LogLevel { func (t *stdLogSystem) GetLogLevel() LogLevel {
return LogLevel(atomic.LoadUint32(&t.level)) 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))
}