mirror of
https://github.com/zyedidia/micro.git
synced 2025-06-18 23:05:40 -04:00
28 lines
447 B
Go
28 lines
447 B
Go
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")
|
|
}
|
|
}
|