log日志bug修改

This commit is contained in:
hsc
2026-06-24 10:18:54 +08:00
parent c4470af013
commit 4deb785135
16 changed files with 169 additions and 101 deletions

View File

@@ -88,7 +88,7 @@ namespace UIShare
}
else
{
LoggerHelper.ErrorWithNotify("程序循环指令未闭合,请检查后重试");
LoggerHelper.ErrorWithNotify(_systemConfig.Title, "程序循环指令未闭合,请检查后重试");
break;
}
}
@@ -108,7 +108,7 @@ namespace UIShare
};
loopStack.Push(context);
step.CurrentLoopCount = context.LoopCount;
LoggerHelper.InfoWithNotify($"循环开始,共{context.LoopCount}次", depth);
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"循环开始,共{context.LoopCount}次", depth);
index++;
}
@@ -117,7 +117,7 @@ namespace UIShare
{
if (loopStack.Count == 0)
{
LoggerHelper.ErrorWithNotify("未匹配的循环结束指令", depth: depth);
LoggerHelper.ErrorWithNotify(_systemConfig.Title, "未匹配的循环结束指令", depth: depth);
step.Result = 2;
index++;
continue;
@@ -133,7 +133,7 @@ namespace UIShare
{
// 继续循环:跳转到循环开始后的第一条指令
index = context.StartIndex + 1;
LoggerHelper.InfoWithNotify($"循环第{context.CurrentLoop}次结束,跳回开始,剩余{context.LoopCount - context.CurrentLoop}次", depth);
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"循环第{context.CurrentLoop}次结束,跳回开始,剩余{context.LoopCount - context.CurrentLoop}次", depth);
}
else
{
@@ -141,7 +141,7 @@ namespace UIShare
loopStack.Pop();
var loopStopwatch = loopStopwatchStack.Peek();
index++;
LoggerHelper.InfoWithNotify($"循环结束,共执行{context.LoopCount}次", depth);
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"循环结束,共执行{context.LoopCount}次", depth);
if (depth == 0 && loopStopwatch.IsRunning)
{
loopStopwatch.Stop();
@@ -168,7 +168,7 @@ namespace UIShare
SubSingleStep = true;
_scopedContext.SingleStep = false;
}
LoggerHelper.InfoWithNotify($"开始执行子程序 [ {step.Index} ] [ {step.Name} ] ", depth);
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"开始执行子程序 [ {step.Index} ] [ {step.Name} ] ", depth);
stepSuccess = await ExecuteSteps(step.SubProgram, depth + 1, cancellationToken);
UpdateCurrentStepResult(step, true, stepSuccess, depth);
if (SubSingleStep)
@@ -179,7 +179,7 @@ namespace UIShare
}
else if (step.Method != null)
{
LoggerHelper.InfoWithNotify($"开始执行指令 [ {step.Index} ] [ {step.Method!.FullName}.{step.Method.Name} ] ", depth);
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"开始执行指令 [ {step.Index} ] [ {step.Method!.FullName}.{step.Method.Name} ] ", depth);
await ExecuteMethodStep(step, tmpParameters, depth, cancellationToken);
stepSuccess = step.Result == 1;
if (step.NGGotoStepID != null && !stepSuccess)
@@ -188,7 +188,7 @@ namespace UIShare
if (tmp != null)
{
index = tmp.Index - 2;
LoggerHelper.InfoWithNotify($"指令跳转 [ {tmp.Index} ] [ {tmp.Name} ]", depth);
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"指令跳转 [ {tmp.Index} ] [ {tmp.Name} ]", depth);
}
}
if (step.OKGotoStepID != null && stepSuccess)
@@ -197,7 +197,7 @@ namespace UIShare
if (tmp != null)
{
index = tmp.Index - 2;
LoggerHelper.InfoWithNotify($"指令跳转 [ {tmp.Index} ] [ {tmp.Name} ]", depth);
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"指令跳转 [ {tmp.Index} ] [ {tmp.Name} ]", depth);
}
}
}
@@ -257,7 +257,7 @@ namespace UIShare
}
else
{
LoggerHelper.ErrorWithNotify("程序循环指令未闭合,请检查后重试");
LoggerHelper.ErrorWithNotify(_systemConfig.Title, "程序循环指令未闭合,请检查后重试");
break;
}
}
@@ -277,7 +277,7 @@ namespace UIShare
};
loopStack.Push(context);
step.CurrentLoopCount = context.LoopCount;
LoggerHelper.InfoWithNotify($"循环开始({step.Name}),共{context.LoopCount}次", depth);
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"循环开始({step.Name}),共{context.LoopCount}次", depth);
index++;
}
@@ -286,7 +286,7 @@ namespace UIShare
{
if (loopStack.Count == 0)
{
LoggerHelper.ErrorWithNotify("未匹配的循环结束指令", depth:depth);
LoggerHelper.ErrorWithNotify(_systemConfig.Title, "未匹配的循环结束指令", depth:depth);
step.Result = 2;
index++;
continue;
@@ -302,7 +302,7 @@ namespace UIShare
{
// 继续循环:跳转到循环开始后的第一条指令
index = context.StartIndex + 1;
LoggerHelper.InfoWithNotify($"循环第{context.CurrentLoop}次结束,跳回开始,剩余{context.LoopCount - context.CurrentLoop}次", depth);
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"循环第{context.CurrentLoop}次结束,跳回开始,剩余{context.LoopCount - context.CurrentLoop}次", depth);
}
else
{
@@ -310,7 +310,7 @@ namespace UIShare
loopStack.Pop();
var loopStopwatch = loopStopwatchStack.Peek();
index++;
LoggerHelper.InfoWithNotify($"循环结束,共执行{context.LoopCount}次", depth);
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"循环结束,共执行{context.LoopCount}次", depth);
if (depth == 0 && loopStopwatch.IsRunning)
{
loopStopwatch.Stop();
@@ -337,7 +337,7 @@ namespace UIShare
SubSingleStep = true;
_scopedContext.SingleStep = false;
}
LoggerHelper.InfoWithNotify($"开始执行子程序 [ {step.Index} ] [ {step.Name} ] ", depth);
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"开始执行子程序 [ {step.Index} ] [ {step.Name} ] ", depth);
stepSuccess = await ExecuteSteps(step.SubProgram, depth + 1, cancellationToken);
UpdateCurrentStepResult(step, true, stepSuccess, depth);
if (SubSingleStep)
@@ -348,7 +348,7 @@ namespace UIShare
}
else if (step.Method != null)
{
LoggerHelper.InfoWithNotify($"开始执行指令 [ {step.Index} ] [ {step.Method!.FullName}.{step.Method.Name} ] ", depth);
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"开始执行指令 [ {step.Index} ] [ {step.Method!.FullName}.{step.Method.Name} ] ", depth);
await ExecuteMethodStep(step, tmpParameters, depth, cancellationToken);
stepSuccess = step.Result == 1;
if (step.NGGotoStepID != null && !stepSuccess)
@@ -357,7 +357,7 @@ namespace UIShare
if (tmp != null)
{
index = tmp.Index - 2;
LoggerHelper.InfoWithNotify($"指令跳转 [ {tmp.Index} ] [ {tmp.Name} ]", depth);
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"指令跳转 [ {tmp.Index} ] [ {tmp.Name} ]", depth);
}
}
if (step.OKGotoStepID != null && stepSuccess)
@@ -366,7 +366,7 @@ namespace UIShare
if (tmp != null)
{
index = tmp.Index - 2;
LoggerHelper.InfoWithNotify($"指令跳转 [ {tmp.Index} ] [ {tmp.Name} ]", depth);
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"指令跳转 [ {tmp.Index} ] [ {tmp.Name} ]", depth);
}
}
}
@@ -408,7 +408,7 @@ namespace UIShare
}
if (targetType == null)
{
LoggerHelper.ErrorWithNotify($"指令 [ {step.Index} ] 执行错误:未找到类型 {step.Method!.FullName}", depth: depth);
LoggerHelper.ErrorWithNotify(_systemConfig.Title, $"指令 [ {step.Index} ] 执行错误:未找到类型 {step.Method!.FullName}", depth: depth);
step.Result = 2;
}
@@ -522,7 +522,7 @@ namespace UIShare
}
catch (Exception ex)
{
LoggerHelper.WarnWithNotify($"指令 [ {step.Index} ] 执行错误:参数 {param.Name} 类型转换失败: {ex.Message}", depth: depth);
LoggerHelper.WarnWithNotify(_systemConfig.Title, $"指令 [ {step.Index} ] 执行错误:参数 {param.Name} 类型转换失败: {ex.Message}", depth: depth);
}
}
}
@@ -546,7 +546,7 @@ namespace UIShare
if (method == null)
{
LoggerHelper.ErrorWithNotify($"指令 [ {step.Index} ] 执行错误:未找到方法{step.Method.Name}", depth: depth);
LoggerHelper.ErrorWithNotify(_systemConfig.Title, $"指令 [ {step.Index} ] 执行错误:未找到方法{step.Method.Name}", depth: depth);
step.Result = 2;
}
@@ -562,7 +562,7 @@ namespace UIShare
}
catch (Exception ex)
{
LoggerHelper.ErrorWithNotify($"指令 [ {step.Index} ] 执行错误:创建实例失败 - {ex.Message}", depth: depth);
LoggerHelper.ErrorWithNotify(_systemConfig.Title, $"指令 [ {step.Index} ] 执行错误:创建实例失败 - {ex.Message}", depth: depth);
step.Result = 2;
}
}
@@ -600,7 +600,7 @@ namespace UIShare
}
catch (Exception ex)
{
LoggerHelper.ErrorWithNotify($"指令 [ {step.Index} ] 执行错误: {ex.InnerException?.Message ?? ex.Message}", depth: depth);
LoggerHelper.ErrorWithNotify(_systemConfig.Title, $"指令 [ {step.Index} ] 执行错误: {ex.InnerException?.Message ?? ex.Message}", depth: depth);
step.Result = 2;
return;
}
@@ -619,7 +619,7 @@ namespace UIShare
paraResult = tmp.Item1;
if (tmp.Item2 != null)
{
LoggerHelper.WarnWithNotify(tmp.Item2);
LoggerHelper.WarnWithNotify(_systemConfig.Title, tmp.Item2);
}
}
@@ -628,19 +628,19 @@ namespace UIShare
{
if (!returnType.IsArray)
{
LoggerHelper.SuccessWithNotify($"输出 [ {outputParam.Name} ] = {returnValue} ({returnType.Name})", depth);
LoggerHelper.SuccessWithNotify(_systemConfig.Title, $"输出 [ {outputParam.Name} ] = {returnValue} ({returnType.Name})", depth);
}
else
{
if (returnValue is IEnumerable enumerable)
{
var elements = enumerable.Cast<object>().Select(item => item?.ToString() ?? "null");
LoggerHelper.SuccessWithNotify($"输出 [ {outputParam.Name} ] = [ {string.Join(", ", elements)} ] ({returnType.Name})", depth);
LoggerHelper.SuccessWithNotify(_systemConfig.Title, $"输出 [ {outputParam.Name} ] = [ {string.Join(", ", elements)} ] ({returnType.Name})", depth);
}
}
}
}
LoggerHelper.SuccessWithNotify($"指令 [ {step.Index} ] 执行成功", depth);
LoggerHelper.SuccessWithNotify(_systemConfig.Title, $"指令 [ {step.Index} ] 执行成功", depth);
UpdateCurrentStepResult(step, paraResult: paraResult, depth: depth);
}
catch (OperationCanceledException)
@@ -649,7 +649,7 @@ namespace UIShare
}
catch (Exception ex)
{
LoggerHelper.ErrorWithNotify($"指令 [ {step.Index} ] 执行错误: {ex.InnerException?.Message ?? ex.Message}", depth: depth);
LoggerHelper.ErrorWithNotify(_systemConfig.Title, $"指令 [ {step.Index} ] 执行错误: {ex.InnerException?.Message ?? ex.Message}", depth: depth);
step.Result = 2;
return;
}
@@ -697,7 +697,7 @@ namespace UIShare
step.Result = re ? 1 : 2;
if (step.Result == 2)
{
LoggerHelper.WarnWithNotify($"指令 [ {step.Index} ] NG:条件表达式验证失败", depth: depth);
LoggerHelper.WarnWithNotify(_systemConfig.Title, $"指令 [ {step.Index} ] NG:条件表达式验证失败", depth: depth);
}
}
}
@@ -705,7 +705,7 @@ namespace UIShare
{
if (!paraResult)
{
LoggerHelper.WarnWithNotify("参数限值校验失败", depth: depth);
LoggerHelper.WarnWithNotify(_systemConfig.Title, "参数限值校验失败", depth: depth);
}
step.Result = 2;
}