提交 c7c7ca10 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

fix issues

上级 01c6dc91
#!/usr/bin/env zsh
:<<!
title=demo1
cid=1
pid=1
1. 1 >> 1
2. 1 >> 1
3. 1 >> 1
4. 1 >> 1
5. 1 >> 1
!
str="abc123"
echo "1"
echo "1"
echo "0"
echo "0"
echo "1"
......@@ -2,7 +2,7 @@
<?php
/**
title=simple demo
title = simple demo
cid=1
pid=1
......
......@@ -2,7 +2,7 @@
<?php
/**
title = expect in file
title =expect in file
cid=0
pid=0
......
......@@ -129,7 +129,7 @@ func appendFailedStepResult(cs commDomain.FuncResult, failedSteps *[]string) (pa
step.Id = strings.TrimRight(step.Id, ".")
status := i118Utils.Sprintf(string(step.Status))
*failedSteps = append(*failedSteps, fmt.Sprintf("Step %s: %s", step.Id, status))
*failedSteps = append(*failedSteps, fmt.Sprintf("Step %s: %s [%s]", step.Id, status, step.Name))
for idx1, cp := range step.CheckPoints {
//cpStatus := commonUtils.BoolToPass(step.Status)
......
......@@ -78,7 +78,7 @@ func ValidateCaseResult(scriptFile string, langType string,
if errOutput != "" && index == 0 && len(checkpointLogs) > 0 {
checkpointLogs[0].Actual = errOutput
}
stepLog := commDomain.StepLog{Id: strconv.Itoa(stepIdxToCheck), Name: stepName, Status: stepResult, CheckPoints: checkpointLogs}
stepLog := commDomain.StepLog{Id: strconv.Itoa(stepIdxToCheck + 1), Name: stepName, Status: stepResult, CheckPoints: checkpointLogs}
stepLogs = append(stepLogs, stepLog)
if stepResult == commConsts.FAIL {
caseResult = commConsts.FAIL
......
......@@ -548,7 +548,7 @@ func GetCaseInfo(file string) (pass bool, caseId, productId int, title string, t
productId, _ = strconv.Atoi(arr[1])
}
myExp = regexp.MustCompile(`[\S\s]*title=([^\n]*?)\n`)
myExp = regexp.MustCompile(`[\S\s]*title\s*=\s*([^\n]*?)\n`)
arr = myExp.FindStringSubmatch(caseInfo)
if len(arr) > 1 {
title = strings.TrimSpace(arr[1])
......
......@@ -34,10 +34,12 @@ func InitLog() {
zapConfig.EncoderConfig.EncodeLevel = nil
zapConfig.DisableCaller = true
zapConfig.EncoderConfig.TimeKey = ""
logUtils.LoggerStandard, err = zapConfig.Build(zap.WrapCore(zapCoreInFile))
logUtils.LoggerStandard, err = zapConfig.Build()
if err != nil {
log.Println("init console logger fail " + err.Error())
}
logUtils.LoggerStandard = logUtils.LoggerStandard.WithOptions(zap.AddCaller(), zap.AddCallerSkip(1))
// print to console and info、err files without stacktrace detail
// by set DisableStacktrace to true
......@@ -46,6 +48,8 @@ func InitLog() {
if err != nil {
log.Println("init exec console logger fail " + err.Error())
}
logUtils.LoggerExecConsole = logUtils.LoggerExecConsole.WithOptions(zap.AddCaller(), zap.AddCallerSkip(1))
}
// write exec results by using zap log
......@@ -64,6 +68,7 @@ func InitExecLog(workspacePath string) {
config.OutputPaths = []string{logPathInfo}
var err error
logUtils.LoggerExecFile, err = config.Build()
logUtils.LoggerExecFile = logUtils.LoggerExecFile.WithOptions(zap.AddCaller(), zap.AddCallerSkip(1))
if err != nil {
log.Println("init exec file logger fail " + err.Error())
......@@ -85,6 +90,7 @@ func InitExecLog(workspacePath string) {
log.Println("init exec result logger fail " + err.Error())
}
logUtils.LoggerExecResult = logUtils.LoggerExecResult.WithOptions(zap.AddCaller(), zap.AddCallerSkip(1))
}
// flush buffer and release the file.
......@@ -123,18 +129,18 @@ func getLogConfig() (config zap.Config) {
}
encoderConfig := zapcore.EncoderConfig{
TimeKey: "time",
LevelKey: "level",
NameKey: "logger",
CallerKey: "caller",
MessageKey: "msg",
StacktraceKey: "stacktrace",
LineEnding: zapcore.DefaultLineEnding,
//EncodeLevel: zapcore.LowercaseLevelEncoder, // 小写编码器
TimeKey: "time",
LevelKey: "level",
NameKey: "logger",
CallerKey: "caller",
MessageKey: "msg",
StacktraceKey: "stacktrace",
LineEnding: zapcore.DefaultLineEnding,
EncodeTime: zapcore.TimeEncoderOfLayout("2006-01-02 15:04:05.000"),
EncodeLevel: zapcore.CapitalColorLevelEncoder, //这里可以指定颜色
EncodeDuration: zapcore.SecondsDurationEncoder,
EncodeCaller: zapcore.FullCallerEncoder, // 全路径编码器
EncodeCaller: zapcore.ShortCallerEncoder, // 路径编码器
//EncodeLevel: zapcore.LowercaseLevelEncoder, // 小写编码器
}
config = zap.Config{
......@@ -144,7 +150,7 @@ func getLogConfig() (config zap.Config) {
EncoderConfig: encoderConfig, // 编码器配置
//InitialFields: map[string]interface{}{"test_machine": "pc1"}, // 初始化字段
}
config.EncoderConfig.EncodeLevel = zapcore.LowercaseColorLevelEncoder //这里可以指定颜色
//if commonUtils.IsWin() {
// zap.RegisterSink("winfile", newWinFileSink)
//}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册