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 ( ...@@ -4,6 +4,7 @@ import (
"io" "io"
"log" "log"
"os" "os"
"path/filepath"
"github.com/hashicorp/go-syslog" "github.com/hashicorp/go-syslog"
"github.com/mholt/caddy" "github.com/mholt/caddy"
...@@ -33,8 +34,11 @@ func setup(c *caddy.Controller) error { ...@@ -33,8 +34,11 @@ func setup(c *caddy.Controller) error {
return err return err
} }
} else { } else {
var file *os.File err := os.MkdirAll(filepath.Dir(rules[i].OutputFile), 0744)
file, err = os.OpenFile(rules[i].OutputFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) 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 { if err != nil {
return err 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