Don't crash on invalid options

This commit is contained in:
Jakob Borg 2014-01-22 12:51:49 +01:00
parent 84c0749d20
commit 0841a46055

View File

@ -74,6 +74,9 @@ var (
)
func main() {
log.SetOutput(os.Stderr)
logger = log.New(os.Stderr, "", log.Flags())
_, err := flags.Parse(&opts)
if err != nil {
if err, ok := err.(*flags.Error); ok {
@ -97,8 +100,6 @@ func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
}
log.SetOutput(os.Stderr)
logger = log.New(os.Stderr, "", log.Flags())
if len(opts.Debug.TraceModel) > 0 || opts.Debug.LogSource {
log.SetFlags(log.Lshortfile | log.Ldate | log.Ltime | log.Lmicroseconds)
logger.SetFlags(log.Lshortfile | log.Ldate | log.Ltime | log.Lmicroseconds)