~yerinalexey/gobin

478164c98843185c65508a38552befc51838da7b — Alexey Yerin 5 months ago 6cfd218
Add option to set log file
1 files changed, 12 insertions(+), 0 deletions(-)

M main.go
M main.go => main.go +12 -0
@@ 22,6 22,7 @@ import (
	"html/template"
	"log"
	"net/http"
	"os"
	"path"
	"strconv"



@@ 34,8 35,19 @@ import (

func main() {
	configFile := flag.String("config", "config.toml", "path to configuration file")
	logFile := flag.String("log", "", "file to write logs to")
	flag.Parse()

	if *logFile != "" {
		f, err := os.Create(*logFile)
		if err != nil {
			log.Fatalln("Could not open log file:", err)
		}
		defer f.Close()

		log.SetOutput(f)
	}

	config, err := config.New(*configFile)

	if err != nil {