func (cf *closeableFile) Write(b []byte) (int, error) {
	cf.mu.RLock()
	defer cf.mu.RUnlock()
	if cf.closed {
		build.Critical("cannot write to the file after it has been closed")
	}
	return cf.File.Write(b)
}
Write takes the input data and writes it to the file.
package persist
import (
	"fmt"
	"io"
	"log"
	"os"
	"sync"
	"github.com/NebulousLabs/Sia/build"
)
type Logger struct {
	*log.Logger
	w io.Writer
}
func (l *Logger) Close() error {
	l.Output(2, "SHUTDOWN: Logging has terminated.")
	if c, ok := l.w.(io.Closer); ok {
		return c.Close()
	}
	return nil
}
func (l *Logger) Critical(v ...interface{}) {
	l.Output(2, "CRITICAL: "+fmt.Sprintln(v...))
	build.Critical(v...)
}
func (l *Logger) Debug(v ...interface{}) {
	if build.DEBUG {
		l.Output(2, fmt.Sprint(v...))
	}
}
func (l *Logger) Debugf(format string, v ...interface{}) {
	if build.DEBUG {
		l.Output(2, fmt.Sprintf(format, v...))
	}
}
func (l *Logger) Debugln(v ...interface{}) {
	if build.DEBUG {
		l.Output(2, "[DEBUG] "+fmt.Sprintln(v...))
	}
}
func (l *Logger) Severe(v ...interface{}) {
	l.Output(2, "SEVERE: "+fmt.Sprintln(v...))
	build.Severe(v...)
}
func NewLogger(w io.Writer) *Logger {
	l := log.New(w, "", log.Ldate|log.Ltime|log.Lmicroseconds|log.Lshortfile|log.LUTC)
	l.Output(3, "STARTUP: Logging has started. Siad Version "+build.Version)  
	return &Logger{l, w}
}
type closeableFile struct {
	*os.File
	closed bool
	mu     sync.RWMutex
}
func (cf *closeableFile) Close() error {
	cf.mu.Lock()
	defer cf.mu.Unlock()
	if cf.closed {
		build.Critical("cannot close the file; already closed")
	}
	if err := cf.Sync(); err != nil {
		return err
	}
	cf.closed = true
	return cf.File.Close()
}