Commit fdc62d01 authored by Matthew Holt's avatar Matthew Holt

log: Create log file directory before creating log file

parent e8e55955
......@@ -4,6 +4,7 @@ import (
"io"
"log"
"os"
"path/filepath"
"github.com/hashicorp/go-syslog"
"github.com/mholt/caddy"
......@@ -33,8 +34,11 @@ func setup(c *caddy.Controller) error {
return err
}
} else {
var file *os.File
file, err = os.OpenFile(rules[i].OutputFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
err := os.MkdirAll(filepath.Dir(rules[i].OutputFile), 0744)
if err != nil {
return err
}
file, err := os.OpenFile(rules[i].OutputFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
if err != nil {
return err
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment