fix debug mode
This commit is contained in:
parent
22d8316f12
commit
1aad6429ae
15
main.go
15
main.go
|
@ -20,6 +20,7 @@ var elog = log.New(os.Stdout, "ERROR: ", 3)
|
||||||
func main() {
|
func main() {
|
||||||
//SETUP FLAGS
|
//SETUP FLAGS
|
||||||
var debugFlag = flag.Bool("debug", false, "help message for flag n")
|
var debugFlag = flag.Bool("debug", false, "help message for flag n")
|
||||||
|
var dirFlag = flag.String("dir", "", "help message")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
clog.Println("Welcome to GoPaper!")
|
clog.Println("Welcome to GoPaper!")
|
||||||
|
@ -47,21 +48,14 @@ func main() {
|
||||||
go slideshow(slideshowDir)
|
go slideshow(slideshowDir)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var dir string
|
slideshowDir <- *dirFlag
|
||||||
args := os.Args[1:]
|
|
||||||
if len(args) > 0 {
|
|
||||||
dir = args[0]
|
|
||||||
} else {
|
|
||||||
dir = config.Default
|
|
||||||
}
|
|
||||||
slideshowDir <- dir
|
|
||||||
|
|
||||||
waitGroup.Wait()
|
waitGroup.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func openLogfile() (*os.File, error) {
|
func openLogfile() (*os.File, error) {
|
||||||
//TODO: log rotation
|
//TODO: log rotation
|
||||||
f, err := os.OpenFile(config.Cache+"/logfile", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
|
f, err := os.OpenFile(config.Cache+"logfile", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -136,7 +130,7 @@ func handleProcesses() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupLogging(debug bool) {
|
func setupLogging(debug bool) {
|
||||||
|
clog.Printf("debug: %v", debug)
|
||||||
//SETUP LOGGERS
|
//SETUP LOGGERS
|
||||||
if debug {
|
if debug {
|
||||||
logfile, err := openLogfile()
|
logfile, err := openLogfile()
|
||||||
|
@ -144,6 +138,7 @@ func setupLogging(debug bool) {
|
||||||
elog.Println("failed to load config", err)
|
elog.Println("failed to load config", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
clog.Printf("Logging to %v", logfile.Name())
|
||||||
log.SetOutput(logfile)
|
log.SetOutput(logfile)
|
||||||
clog.SetOutput(logfile)
|
clog.SetOutput(logfile)
|
||||||
elog.SetOutput(logfile)
|
elog.SetOutput(logfile)
|
||||||
|
|
Loading…
Reference in New Issue