添加了很多日志
This commit is contained in:
parent
776b221b3d
commit
d328fcfdfb
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Default": "Debug",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
"Default": "Debug",
|
||||
"Microsoft": "Debug",
|
||||
"Microsoft.Hosting.Lifetime": "Debug"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace ShardingCore.Core.VirtualRoutes.TableRoutes.RoutingRuleEngine
|
|||
}
|
||||
public string GetPrintInfo()
|
||||
{
|
||||
return $"table route result:has different tail:{HasDifferentTail},current table:[{string.Join(",", ReplaceTables.Select(o => o.FullName))}]";
|
||||
return $"(has different tail:{HasDifferentTail},current table:[{string.Join(",", ReplaceTables.Select(o => o.FullName))}])";
|
||||
}
|
||||
|
||||
#if !EFCORE2
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace ShardingCore.Sharding.ShardingExecutors
|
|||
public TResult Execute<TResult>(IShardingDbContext shardingDbContext, Expression query)
|
||||
{
|
||||
var compileParameter = new CompileParameter(shardingDbContext,query);
|
||||
_logger.LogDebug(compileParameter.GetPrintInfo());
|
||||
_logger.LogDebug($"compile parameter:{compileParameter.GetPrintInfo()}");
|
||||
using (new CustomerQueryScope(compileParameter))
|
||||
{
|
||||
var queryCompilerContext = _queryCompilerContextFactory.Create(compileParameter);
|
||||
|
@ -42,7 +42,7 @@ namespace ShardingCore.Sharding.ShardingExecutors
|
|||
CancellationToken cancellationToken = new CancellationToken())
|
||||
{
|
||||
var compileParameter = new CompileParameter(shardingDbContext,query);
|
||||
_logger.LogDebug(compileParameter.GetPrintInfo());
|
||||
_logger.LogDebug($"compile parameter:{compileParameter.GetPrintInfo()}");
|
||||
|
||||
using (new CustomerQueryScope(compileParameter))
|
||||
{
|
||||
|
@ -56,7 +56,7 @@ namespace ShardingCore.Sharding.ShardingExecutors
|
|||
public IAsyncEnumerable<TResult> ExecuteAsync<TResult>(IShardingDbContext shardingDbContext, Expression query)
|
||||
{
|
||||
var compileParameter = new CompileParameter(shardingDbContext,query);
|
||||
_logger.LogDebug(compileParameter.GetPrintInfo());
|
||||
_logger.LogDebug($"compile parameter:{compileParameter.GetPrintInfo()}");
|
||||
using (new CustomerQueryScope(compileParameter))
|
||||
{
|
||||
var queryCompilerContext = _queryCompilerContextFactory.Create(compileParameter);
|
||||
|
@ -68,7 +68,7 @@ namespace ShardingCore.Sharding.ShardingExecutors
|
|||
CancellationToken cancellationToken)
|
||||
{
|
||||
var compileParameter = new CompileParameter(shardingDbContext,query);
|
||||
_logger.LogDebug(compileParameter.GetPrintInfo());
|
||||
_logger.LogDebug($"compile parameter:{compileParameter.GetPrintInfo()}");
|
||||
using (new CustomerQueryScope(compileParameter))
|
||||
{
|
||||
var queryCompilerContext = _queryCompilerContextFactory.Create(compileParameter);
|
||||
|
|
|
@ -11,6 +11,8 @@ using System.Linq;
|
|||
using System.Linq.Expressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ShardingCore.Core;
|
||||
#if EFCORE2
|
||||
using Microsoft.EntityFrameworkCore.Internal;
|
||||
#endif
|
||||
|
@ -26,6 +28,12 @@ namespace ShardingCore.Sharding.ShardingQueryExecutors
|
|||
*/
|
||||
public class DefaultShardingQueryExecutor : IShardingQueryExecutor
|
||||
{
|
||||
private readonly ILogger<DefaultShardingQueryExecutor> _logger;
|
||||
|
||||
public DefaultShardingQueryExecutor(ILogger<DefaultShardingQueryExecutor> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public TResult Execute<TResult>(IMergeQueryCompilerContext mergeQueryCompilerContext)
|
||||
{
|
||||
|
@ -110,8 +118,18 @@ namespace ShardingCore.Sharding.ShardingQueryExecutors
|
|||
|
||||
var streamMergeContextMethod = streamMergeContextFactory.GetType().GetMethod(nameof(IStreamMergeContextFactory.Create));
|
||||
if (streamMergeContextMethod == null)
|
||||
throw new ShardingCoreException($"cant found IStreamMergeContextFactory method [{nameof(IStreamMergeContextFactory.Create)}]");
|
||||
throw new ShardingCoreException($"cant found {nameof(IStreamMergeContextFactory)} method [{nameof(IStreamMergeContextFactory.Create)}]");
|
||||
#if DEBUG
|
||||
var streamMergeContext= streamMergeContextMethod.MakeGenericMethod(new Type[] { resultType }).Invoke(streamMergeContextFactory, new object[] { mergeQueryCompilerContext });
|
||||
if (streamMergeContext is IPrint print)
|
||||
{
|
||||
_logger.LogDebug(print.GetPrintInfo());
|
||||
}
|
||||
return streamMergeContext;
|
||||
#endif
|
||||
#if !DEBUG
|
||||
return streamMergeContextMethod.MakeGenericMethod(new Type[] { resultType }).Invoke(streamMergeContextFactory, new object[] { mergeQueryCompilerContext });
|
||||
#endif
|
||||
|
||||
}
|
||||
private TResult EnumerableExecute<TResult>(IMergeQueryCompilerContext mergeQueryCompilerContext)
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace ShardingCore.Sharding.ShardingExecutors
|
|||
var dataSourceRouteResult = dataSourceRouteRuleEngineFactory.Route(queryCombineResult.GetCombineQueryable(), compileParameter.GetShardingDbContext());
|
||||
_logger.LogDebug(dataSourceRouteResult.GetPrintInfo());
|
||||
var routeResults = tableRouteRuleEngineFactory.Route(queryCombineResult.GetCombineQueryable()).ToArray();
|
||||
_logger.LogDebug($"table route results:{string.Join(",",routeResults.Select(o=>o.GetPrintInfo()))}");
|
||||
_logger.LogDebug($"table route results:{string.Join(","+Environment.NewLine,routeResults.Select(o=>o.GetPrintInfo()))}");
|
||||
var mergeCombineCompilerContext = MergeQueryCompilerContext.Create(queryCompilerContext, queryCombineResult, dataSourceRouteResult,
|
||||
routeResults);
|
||||
return mergeCombineCompilerContext;
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace ShardingCore.Sharding
|
|||
* @Date: Monday, 25 January 2021 11:38:27
|
||||
* @Email: 326308290@qq.com
|
||||
*/
|
||||
public class StreamMergeContext<TEntity> : ISeqQueryProvider, IDisposable
|
||||
public class StreamMergeContext<TEntity> : ISeqQueryProvider, IDisposable,IPrint
|
||||
#if !EFCORE2
|
||||
, IAsyncDisposable
|
||||
#endif
|
||||
|
@ -497,5 +497,11 @@ namespace ShardingCore.Sharding
|
|||
{
|
||||
return TableRouteResults.Length > GetMaxQueryConnectionsLimit();
|
||||
}
|
||||
|
||||
public string GetPrintInfo()
|
||||
{
|
||||
return
|
||||
$"stream merge context:[max query connections limit:{GetMaxQueryConnectionsLimit()}],[is use read write separation:{IsUseReadWriteSeparation()}],[is parallel query:{IsParallelQuery()}],[is not support sharding:{IsNotSupportSharding()}],[is sequence query:{IsSeqQuery()}],[can trip:{CanTrip()}],[is route not match:{IsRouteNotMatch()}],[throw if query route not match:{ThrowIfQueryRouteNotMatch()}],[is pagination query:{IsPaginationQuery()}],[has group query:{HasGroupQuery()}],[is merge query:{IsMergeQuery()}],[is single sharding entity query:{IsSingleShardingEntityQuery()}]";
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue