func NewSimpleWriter(writer io.Writer, formatter Formatter) Writer {
	return &simpleWriter{writer, formatter}
}
NewSimpleWriter returns a new writer that writes
log messages to the given io.Writer formatting the
messages with the given formatter.
package loggo
import (
	"fmt"
	"io"
	"os"
	"sync"
	"time"
)
type Writer interface {
	Write(level Level, name, filename string, line int, timestamp time.Time, message string)
}
type registeredWriter struct {
	writer Writer
	level  Level
}
const defaultName = "default"
var (
	writerMutex sync.Mutex
	writers     = map[string]*registeredWriter{
		defaultName: &registeredWriter{
			writer: NewSimpleWriter(os.Stderr, &DefaultFormatter{}),
			level:  TRACE,
		},
	}
	globalMinLevel = TRACE
)
func ResetWriters() {
	writerMutex.Lock()
	defer writerMutex.Unlock()
	writers = map[string]*registeredWriter{
		"default": &registeredWriter{
			writer: NewSimpleWriter(os.Stderr, &DefaultFormatter{}),
			level:  TRACE,
		},
	}
	findMinLevel()
}
func ReplaceDefaultWriter(writer Writer) (Writer, error) {
	if writer == nil {
		return nil, fmt.Errorf("Writer cannot be nil")
	}
	writerMutex.Lock()
	defer writerMutex.Unlock()
	reg, found := writers[defaultName]
	if !found {
		return nil, fmt.Errorf("there is no %q writer", defaultName)
	}
	oldWriter := reg.writer
	reg.writer = writer
	return oldWriter, nil
}
func RegisterWriter(name string, writer Writer, minLevel Level) error {
	if writer == nil {
		return fmt.Errorf("Writer cannot be nil")
	}
	writerMutex.Lock()
	defer writerMutex.Unlock()
	if _, found := writers[name]; found {
		return fmt.Errorf("there is already a Writer registered with the name %q", name)
	}
	writers[name] = &registeredWriter{writer: writer, level: minLevel}
	findMinLevel()
	return nil
}
func RemoveWriter(name string) (Writer, Level, error) {
	writerMutex.Lock()
	defer writerMutex.Unlock()
	registered, found := writers[name]
	if !found {
		return nil, UNSPECIFIED, fmt.Errorf("Writer %q is not registered", name)
	}
	delete(writers, name)
	findMinLevel()
	return registered.writer, registered.level, nil
}
func findMinLevel() {
	minLevel := CRITICAL
	for _, registered := range writers {
		if registered.level < minLevel {
			minLevel = registered.level
		}
	}
	globalMinLevel.set(minLevel)
}
func WillWrite(level Level) bool {
	return level >= globalMinLevel.get()
}
func writeToWriters(level Level, module, filename string, line int, timestamp time.Time, message string) {
	writerMutex.Lock()
	defer writerMutex.Unlock()
	for _, registered := range writers {
		if level >= registered.level {
			registered.writer.Write(level, module, filename, line, timestamp, message)
		}
	}
}
type simpleWriter struct {
	writer    io.Writer
	formatter Formatter
}