infra
/
goutils
Archived
1
0
Fork 0

=changed path from log

This commit is contained in:
Sangbum Kim 2018-06-12 22:50:41 +09:00
parent 9b8d325761
commit a9a06fd142
1 changed files with 4 additions and 3 deletions

View File

@ -2,7 +2,7 @@ package rotater
import ( import (
"os" "os"
"path" "path/filepath"
"log" "log"
"amuz.es/src/infra/goutils/logger" "amuz.es/src/infra/goutils/logger"
"github.com/lestrrat-go/file-rotatelogs" "github.com/lestrrat-go/file-rotatelogs"
@ -19,11 +19,12 @@ func NewLogWriter(FileName string, logDir string, options ...Option) (logger.Rot
default: default:
logpath := FileName logpath := FileName
if logDir != "" { if logDir != "" {
logpath = path.Join(logDir, FileName) logpath = filepath.Join(logDir, FileName)
} }
logpath,_ = filepath.Abs(logpath)
log.Println(" Attention!! log writes to ", logpath) log.Println(" Attention!! log writes to ", logpath)
options=append(options,rotatelogs.WithLinkName(logpath)) options=append(options,rotatelogs.WithLinkName(logpath))
if logWriter, err := NewRotater(logpath+".%Y%M%D", options...); err != nil { if logWriter, err := NewRotater(logpath+".%Y%m%d", options...); err != nil {
return nil, err return nil, err
} else { } else {
loggers.Store(logWriter) loggers.Store(logWriter)