package nazalog: mkdir 777

pull/2/head
q191201771 5 years ago
parent f45eec9e61
commit 7ab7fd01b5

@ -96,7 +96,7 @@ func New(modOptions ...ModOption) (Logger, error) {
} }
if l.option.Filename != "" { if l.option.Filename != "" {
l.dir = filepath.Dir(l.option.Filename) l.dir = filepath.Dir(l.option.Filename)
if err = os.MkdirAll(l.dir, 0666); err != nil { if err = os.MkdirAll(l.dir, 0777); err != nil {
return nil, err return nil, err
} }
if l.fp, err = os.OpenFile(l.option.Filename, os.O_CREATE | os.O_WRONLY | os.O_APPEND, 0666); err != nil { if l.fp, err = os.OpenFile(l.option.Filename, os.O_CREATE | os.O_WRONLY | os.O_APPEND, 0666); err != nil {

@ -13,7 +13,7 @@ import (
func TestLogger(t *testing.T) { func TestLogger(t *testing.T) {
l, err := New(func(option *Option) { l, err := New(func(option *Option) {
option.Level = LevelInfo option.Level = LevelInfo
option.Filename = "/tmp/lallogtest/aaa.log" option.Filename = "/tmp/nazalogtest/aaa.log"
option.IsToStdout = true option.IsToStdout = true
option.IsRotateDaily = true option.IsRotateDaily = true
}) })
@ -47,7 +47,7 @@ func TestGlobal(t *testing.T) {
err := Init(func(option *Option) { err := Init(func(option *Option) {
option.Level = LevelInfo option.Level = LevelInfo
option.Filename = "/tmp/lallogtest/bbb.log" option.Filename = "/tmp/nazalogtest/bbb.log"
option.IsToStdout = true option.IsToStdout = true
}) })
@ -92,7 +92,7 @@ func TestNew(t *testing.T) {
func TestRotate(t *testing.T) { func TestRotate(t *testing.T) {
err := Init(func(option *Option) { err := Init(func(option *Option) {
option.Level = LevelInfo option.Level = LevelInfo
option.Filename = "/tmp/lallogtest/ccc.log" option.Filename = "/tmp/nazalogtest/ccc.log"
option.IsToStdout = false option.IsToStdout = false
option.IsRotateDaily = true option.IsRotateDaily = true

Loading…
Cancel
Save