-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
51 additions
and
57 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
time="2017-10-20T16:59:41+08:00" level=info msg="test displayHandler" adNum=1 appId=1 creativeId=456 deviceId=0x22q53 iP=127.0.0.1 oS=1 osVersion=1.0.0 searchId=123 slotId=2 unitId=123 | ||
time="2017-10-20T16:59:59+08:00" level=info msg="test displayHandler" adNum=1 appId=1 creativeId=456 deviceId=0x22q53 iP=127.0.0.1 oS=1 osVersion=1.0.0 searchId=123 slotId=2 unitId=123 | ||
time="2017-10-20T16:59:59+08:00" level=info msg="test displayHandler" adNum=1 appId=1 creativeId=456 deviceId=0x22q53 iP=127.0.0.1 oS=1 osVersion=1.0.0 searchId=123 slotId=2 unitId=123 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package adhandler | ||
import ( | ||
"github.com/lestrrat/go-file-rotatelogs" | ||
"github.com/rifflock/lfshook" | ||
"github.com/sirupsen/logrus" | ||
"time" | ||
"github.com/pkg/errors" | ||
"path" | ||
) | ||
var adLog=logrus.New() | ||
// config logrus log to local filesystem, with file rotation | ||
func ConfigLocalFilesystemLogger(logPath string, logFileName string, maxAge time.Duration, rotationTime time.Duration) { | ||
baseLogPaht := path.Join(logPath, logFileName) | ||
writer, err := rotatelogs.New( | ||
baseLogPaht+".%Y%m%d%H%M", | ||
// rotatelogs.WithLinkName(baseLogPaht), // 生成软链,指向最新日志文件 | ||
rotatelogs.WithMaxAge(maxAge), // 文件最大保存时间 | ||
rotatelogs.WithRotationTime(rotationTime), // 日志切割时间间隔 | ||
) | ||
if err != nil { | ||
adLog.Errorf("config local file system logger error. %+v", errors.WithStack(err)) | ||
} | ||
lfHook := lfshook.NewHook(lfshook.WriterMap{ | ||
logrus.DebugLevel: writer, // 为不同级别设置不同的输出目的 | ||
logrus.InfoLevel: writer, | ||
logrus.WarnLevel: writer, | ||
logrus.ErrorLevel: writer, | ||
logrus.FatalLevel: writer, | ||
logrus.PanicLevel: writer, | ||
}) | ||
adLog.AddHook(lfHook) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters