Start refactor

This commit is contained in:
Zachary Yedidia
2018-08-25 23:06:44 -04:00
parent d9735e5c3b
commit dc68183fc1
51 changed files with 1621 additions and 10822 deletions

27
cmd/micro/debug.go Normal file
View File

@@ -0,0 +1,27 @@
package main
import (
"log"
"os"
)
type NullWriter struct{}
func (NullWriter) Write(data []byte) (n int, err error) {
return 0, nil
}
func InitLog() {
if Debug == "ON" {
f, err := os.OpenFile("log.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
log.Fatalf("error opening file: %v", err)
}
log.SetOutput(f)
log.Println("Micro started")
} else {
log.SetOutput(NullWriter{})
log.Println("Micro started")
}
}