operation:sqlDebug 调试开启
外部注入
private readonly IDebugProvider _debugProvider;
/// <summary>
///
/// </summary>
/// <param name="configuration"></param>
public DebugProviderUsed(IDebugProvider debugProvider)
{
_debugProvider = debugProvider;
}
性能分析
/// <summary>
/// 性能分析
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="pfParams"></param>
/// <param name="content"></param>
/// <param name="className"></param>
/// <param name="funName"></param>
/// <param name="dateStartNow"></param>
/// <returns></returns>
public async Task DoAnalysis<T>(PFGlobalParameter pfParams, T content, string className, string funName, DateTime dateStartNow)
{
await Task.Run(() =>
{
if (_configuration.GetValue<bool>("operation:analysisDebug"))
{
FileUtil.LoadAnalysis(className, funName, $"ownerId:{pfParams.OwnerId}--ModuleKey:{pfParams.ModuleKey}--resField:{pfParams.ReponseField}", (DateTime.Now - dateStartNow).TotalMilliseconds);
}
});
}
执行的sql语句,便于分析
```coffeescript
/// <summary>
/// 执行的sql语句,便于分析
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="pf"></param>
/// <param name="content"></param>
/// <returns></returns>
public async Task DoSql<T>(PFGlobalParameter pf, T content)
{
await Task.Run(() =>
{
if (_configuration.GetValue<bool>("operation:sqlDebug"))
{
FileUtil.CreateFileAndContent($"~/App_Caches/SqlDebug/{pf.OwnerId}/{pf.ModuleKey}/{DateTime.Now.ToString("yyyyMMdd")}/debug-{Guid.NewGuid()}.json", JsonUtil.Serialize(content ?? default, false, false, false), "UTF8");
}
});
}
### 错误信息,便于开发源码外调试
```coffeescript
/// <summary>
/// 错误信息,便于开发源码外调试
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="pf"></param>
/// <param name="content"></param>
/// <returns></returns>
public async Task DoError<T>(PFGlobalParameter pf, T content)
{
await Task.Run(() =>
{
if (_configuration.GetValue<bool>("operation:sqlDebug"))
{
string funName = "error-funs";
FileUtil.CreateFileAndContent($"~/App_Caches/SqlDebug/{pf.OwnerId}/{pf.FunName ?? funName}/{pf.ModuleKey}/{DateTime.Now.ToString("yyyyMMdd")}/error-{Guid.NewGuid()}.json", JsonUtil.Serialize(content ?? default, false, false, false), "UTF8");
}
});
}
文档更新时间: 2021-08-25 08:00 作者:admin