本文整理汇总了C#中ILogger.Trace方法的典型用法代码示例。如果您正苦于以下问题:C# ILogger.Trace方法的具体用法?C# ILogger.Trace怎么用?C# ILogger.Trace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILogger
的用法示例。
在下文中一共展示了ILogger.Trace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Emitter
public Emitter(IDictionary<string,
TypeDefinition> typeDefinitions,
BridgeTypes bridgeTypes,
List<ITypeInfo> types,
IValidator validator,
IMemberResolver resolver,
Dictionary<string, ITypeInfo> typeInfoDefinitions,
ILogger logger)
{
this.Log = logger;
this.Resolver = resolver;
this.TypeDefinitions = typeDefinitions;
this.TypeInfoDefinitions = typeInfoDefinitions;
this.Types = types;
this.BridgeTypes = bridgeTypes;
this.BridgeTypes.InitItems(this);
logger.Trace("Sorting types infos by name...");
this.Types.Sort(this.CompareTypeInfosByName);
logger.Trace("Sorting types infos by name done");
this.SortTypesByInheritance();
this.Validator = validator;
this.AssignmentType = ICSharpCode.NRefactory.CSharp.AssignmentOperatorType.Any;
this.UnaryOperatorType = ICSharpCode.NRefactory.CSharp.UnaryOperatorType.Any;
this.JsDoc = new JsDoc();
}
示例2: InitializeNonparsablePropertiesRecursive
private static IEnumerable<IConceptInfo> InitializeNonparsablePropertiesRecursive(IAlternativeInitializationConcept alternativeInitializationConcept, HashSet<string> alreadyCreated, int depth, ILogger traceLogger)
{
if (depth > 10)
throw new DslSyntaxException(alternativeInitializationConcept, "Macro concept references cannot be resolved.");
List<IConceptInfo> result = new List<IConceptInfo>();
IEnumerable<IConceptInfo> createdConcepts;
alternativeInitializationConcept.InitializeNonparsableProperties(out createdConcepts);
CsUtility.Materialize(ref createdConcepts);
if (createdConcepts != null && createdConcepts.Count() > 0)
{
traceLogger.Trace(() => alternativeInitializationConcept.GetShortDescription() + " generated on alternative initialization: "
+ string.Join(", ", createdConcepts.Select(c => c.GetShortDescription())) + ".");
result.AddRange(createdConcepts);
foreach (var concept in createdConcepts.OfType<IAlternativeInitializationConcept>())
if (!alreadyCreated.Contains(concept.GetFullDescription()))
{
alreadyCreated.Add(concept.GetFullDescription());
result.AddRange(InitializeNonparsablePropertiesRecursive(concept, alreadyCreated, depth + 1, traceLogger));
}
}
return result;
}
示例3: Filter
public override IResourceDataResult Filter(IResourceDataRequest request, ISynchronousFilterChain chain, ILogger logger)
{
bool cacheEnabled = this.cacheResolver.IsSynchronousSupported;
if (!cacheEnabled)
{
return chain.Filter(request, logger);
}
bool isDelete = request.Action == ResourceAction.Delete;
bool isCustomDataPropertyRequest = request.Uri.ResourcePath.ToString().Contains("/customData/");
if (isCustomDataPropertyRequest && isDelete)
{
logger.Trace($"Request {request.Action} {request.Uri} is a custom data property delete, deleting cached property name if exists", "WriteCacheFilter.FilterAsync");
this.UncacheCustomDataProperty(request.Uri.ResourcePath, logger);
}
else if (isDelete)
{
logger.Trace($"Request {request.Action} {request.Uri} is a resource deletion, purging from cache if exists", "WriteCacheFilter.Filter");
var cacheKey = this.GetCacheKey(request);
this.Uncache(request.Type, cacheKey);
}
var result = chain.Filter(request, logger);
bool isEmailVerificationResponse = result.Type == typeof(IEmailVerificationToken);
if (isEmailVerificationResponse)
{
logger.Trace($"Request {request.Action} {request.Uri} is an email verification request, purging account from cache if exists", "WriteCacheFilter.Filter");
this.UncacheAccountOnEmailVerification(result);
}
bool possibleCustomDataUpdate = (request.Action == ResourceAction.Create || request.Action == ResourceAction.Update) &&
AbstractExtendableInstanceResource.IsExtendable(request.Type);
if (possibleCustomDataUpdate)
{
this.CacheNestedCustomDataUpdates(request, result, logger);
}
if (IsCacheable(request, result))
{
logger.Trace($"Caching request {request.Action} {request.Uri}", "WriteCacheFilter.Filter");
this.Cache(result.Type, result.Body, logger);
}
return result;
}
示例4: ContactCalendarEventsHub
public ContactCalendarEventsHub(IContactRepository contactRepository, IEnumerable<ICalendarProvider> calendarProviders, ILoginProvider sessionProvider, ILoggerFactory loggerFactory)
{
Debug.Print("ContactCalendarEventsHub.ctor()");
_contactRepository = contactRepository;
_calendarProviders = calendarProviders.ToArray();
_sessionProvider = sessionProvider;
_logger = loggerFactory.CreateLogger(GetType());
_logger.Trace("ContactCalendarEventsHub.ctor(calendarProviders:{0})", string.Join(",", _calendarProviders.Select(cp=>cp.GetType().Name)));
}
示例5: ContactGalleryAlbumsHub
public ContactGalleryAlbumsHub(IContactRepository contactRepository, IEnumerable<IGalleryProvider> galleryProviders, ILoginProvider sessionProvider, ILoggerFactory loggerFactory)
{
Debug.Print("ContactGalleryAlbumsHub.ctor()");
_contactRepository = contactRepository;
_galleryProviders = galleryProviders.ToArray();
_sessionProvider = sessionProvider;
_logger = loggerFactory.CreateLogger(GetType());
_logger.Trace("ContactGalleryAlbumsHub.ctor(galleryProviders:{0})", string.Join(",", _galleryProviders.Select(cp => cp.GetType().Name)));
}
示例6: Filter
public override IResourceDataResult Filter(IResourceDataRequest request, ISynchronousFilterChain chain, ILogger logger)
{
bool cacheEnabled =
this.cacheResolver.IsAsynchronousSupported
&& this.IsCacheRetrievalEnabled(request)
&& !request.SkipCache;
if (cacheEnabled)
{
logger.Trace($"Checking cache for resource {request.Uri}", "ReadCacheFilter.Filter");
var result = this.GetCachedResourceData(request, logger);
if (result != null)
{
logger.Trace($"Cache hit for {request.Uri}; returning cached data", "ReadCacheFilter.Filter");
return result; // short-circuit the remainder of the filter chain
}
logger.Trace($"Cache miss for {request.Uri}", "ReadCacheFilter.Filter");
}
return chain.Filter(request, logger);
}
示例7: FilterAsync
public override async Task<IResourceDataResult> FilterAsync(IResourceDataRequest request, IAsynchronousFilterChain chain, ILogger logger, CancellationToken cancellationToken)
{
bool cacheEnabled =
this.cacheResolver.IsAsynchronousSupported
&& this.IsCacheRetrievalEnabled(request)
&& !request.SkipCache;
if (cacheEnabled)
{
logger.Trace($"Checking cache for resource {request.Uri}", "ReadCacheFilter.FilterAsync");
var result = await this.GetCachedResourceDataAsync(request, logger, cancellationToken).ConfigureAwait(false);
if (result != null)
{
logger.Trace($"Cache hit for {request.Uri}; returning cached data", "ReadCacheFilter.FilterAsync");
return result; // short-circuit the remainder of the filter chain
}
logger.Trace($"Cache miss for {request.Uri}", "ReadCacheFilter.FilterAsync");
}
return await chain.FilterAsync(request, logger, cancellationToken).ConfigureAwait(false);
}
示例8: GetContainerHref
IResourceDataResult ISynchronousFilter.Filter(IResourceDataRequest request, ISynchronousFilterChain chain, ILogger logger)
{
var result = chain.Filter(request, logger);
if (!IsCreateOrUpdate(request))
{
return result; // short-circuit
}
if (!IsAccountStoreMapping(result))
{
return result; // short-circuit
}
var applicationHref = GetContainerHref("application", result);
if (!string.IsNullOrEmpty(applicationHref))
{
var application = chain.DataStore.GetResourceSkipCache<IApplication>(applicationHref);
var allMappings = application.GetAccountStoreMappings().Synchronously().ToList();
logger.Trace($"AccountStoreMapping update detected; refreshing all {allMappings.Count} AccountStoreMappings in cache for Application '{applicationHref}'", "AccountStoreMappingCacheInvalidationFilter.Filter");
return result; // done
}
var organizationHref = GetContainerHref("organization", result);
if (!string.IsNullOrEmpty(organizationHref))
{
var organization = chain.DataStore.GetResourceSkipCache<IOrganization>(organizationHref);
var allMappings = organization.GetAccountStoreMappings().Synchronously().ToList();
logger.Trace($"AccountStoreMapping update detected; refreshing all {allMappings.Count} AccountStoreMappings in cache for Organization '{organizationHref}'", "AccountStoreMappingCacheInvalidationFilter.Filter");
return result; // done
}
throw new NotSupportedException($"Unsupported AccountStore container type: {request.Type.Name}");
}
开发者ID:ssankar1234,项目名称:stormpath-sdk-dotnet,代码行数:38,代码来源:AccountStoreMappingCacheInvalidationFilter.cs
示例9: LogResult
internal static void LogResult(JobResult result, ILogger logger, string jobName) {
if (result != null) {
if (result.IsCancelled)
logger.Warn(result.Error, "Job run \"{0}\" cancelled: {1}", jobName, result.Message);
else if (!result.IsSuccess)
logger.Error(result.Error, "Job run \"{0}\" failed: {1}", jobName, result.Message);
else if (!String.IsNullOrEmpty(result.Message))
logger.Info("Job run \"{0}\" succeeded: {1}", jobName, result.Message);
else
logger.Trace("Job run \"{0}\" succeeded.", jobName);
} else {
logger.Error("Null job run result for \"{0}\".", jobName);
}
}
示例10: RouterManager
public RouterManager()
{
_logger = LogManager.GetCurrentClassLogger();
_logger.Trace("Creating RouteManager");
_config = new Config();
_homePageUrl = _config.BaseUrl + "/html/home.html";
_publicRsaKeyUrl = _config.BaseUrl + "/api/webserver/publickey";
_loginPageUrl = _config.BaseUrl + "/api/user/login";
_networkChangeUrl = _config.BaseUrl + "/api/net/net-mode";
_connectionStatusUrl = _config.BaseUrl + "/api/monitoring/status";
_logger.Trace("Initializing JS engine");
InitJsEngine();
_logger.Trace("Initializing JS engine... Done");
_website = new WebSite();
_logger.Trace("Creating RouteManager... Done");
IsInitialized = true;
}
示例11: LogWithLogger
private static void LogWithLogger(LogItem logItem, ILogger logger)
{
switch (logItem.LogLevel)
{
case LogLevel.Trace:
logger.Trace(() => logItem.Message, logItem.Exception);
break;
case LogLevel.Info:
logger.Info(() => logItem.Message, logItem.Exception);
break;
case LogLevel.Warn:
logger.Warn(() => logItem.Message, logItem.Exception);
break;
case LogLevel.Error:
logger.Error(() => logItem.Message, logItem.Exception);
break;
case LogLevel.Fatal:
logger.Fatal(() => logItem.Message, logItem.Exception);
break;
}
}
示例12: ModelCreatingByEntityTypeConfiguration
/// <summary>
/// Построить модель с помощью EntityTypeConfiguration
/// </summary>
/// <param name="modelBuilder">Построитель модели</param>
/// <param name="logger">Логировщик</param>
/// <param name="namespaceMap">Пространство имен для мапинга</param>
private static void ModelCreatingByEntityTypeConfiguration(
DbModelBuilder modelBuilder,
ILogger logger,
params string[] namespaceMap)
{
logger.Trace("Начинаем конфигурировать контекст БД");
var typesToRegister =
PathExtension.GetAssemblyCurrentDirectory()
.AsParallel()
.SelectMany(
a =>
a.GetTypes()
.Where(type => CheckNamespace(type.Namespace, namespaceMap))
.Where(type => !type.IsAbstract)
.Where(IsEntityTypeConfiguration))
.ToList();
logger.Trace("Найдено: {0} мапинг объектов", typesToRegister.Count);
foreach (var type in typesToRegister)
{
try
{
dynamic configurationInstance = Activator.CreateInstance(type);
modelBuilder.Configurations.Add(configurationInstance);
logger.Trace("Тип {0} зарегистрирован", type.FullName);
}
catch (Exception exception)
{
logger.Trace("Тип {0} ошибка", type.FullName);
logger.Error(exception);
}
}
logger.Trace("Закончили конфигурировать контекст БД");
}
示例13: GenerateSqlDiff
public string GenerateSqlDiff(
IEnumerable<IMap> fromMaps,
IEnumerable<IMap> toMaps,
IAnswerProvider answerProvider,
ILogger logger,
IEnumerable<string> indexesToIgnore,
IEnumerable<string> tablesToIgnore,
out IEnumerable<string> warnings,
out IEnumerable<string> errors) {
// fetch data for current database
IDictionary<string, Statistics> currentData = new Dictionary<string, Statistics>();
if (fromMaps.Any()) {
currentData = this.statisticsProvider.GetStatistics(fromMaps);
}
var sql = new StringBuilder();
var warningList = new List<string>();
var errorList = new List<string>();
var renamePrimaryKeyModifications = new Dictionary<Tuple<string, string>, bool>();
var from = fromMaps.ToArray();
var to = toMaps.ToArray();
// get additions and removals
var mapComparer = new TableNameEqualityComparer();
var additions = to.Except(from, mapComparer).Where(m => !tablesToIgnore.Contains(m.Table)).ToList();
var removals = from.Except(to, mapComparer).ToList();
var matches = from.Join(to, f => f.Table.ToLowerInvariant(), t => t.Table.ToLowerInvariant(), MigrationPair.Of).ToList();
// trace output
logger.Trace("Additions:");
logger.Trace("");
logger.Trace(additions.Select(a => new { a.Table, a.Type.Name }), new[] { "Table", "Map Name" });
logger.Trace("Removals:");
logger.Trace("");
logger.Trace(removals.Select(r => new { r.Table, r.Type.Name }), new[] { "Table", "Map Name" });
logger.Trace("Matches:");
logger.Trace("");
logger.Trace(
matches.Select(m => new { FromTable = m.From.Table, FromMap = m.From.Type.Name, ToTable = m.To.Table, ToMap = m.To.Type.Name }),
new[] { "From Table", "From Map", "To Table", "To Map" });
// look for possible entity name changes
if (additions.Any() && removals.Any()) {
// TODO do something a bit more sensible with regards to likelihood of rename
foreach (var removed in removals.Select(r => r).ToArray()) {
// copy the array as we'll update
var answer =
answerProvider.GetMultipleChoiceAnswer(
string.Format("The entity {0} has been removed. If it has been renamed please specify what to:", removed.Type.Name),
new[] { new MultipleChoice<string> { DisplayString = "Not renamed - please delete", Choice = NoRename } }.Union(
additions.Select(a => new MultipleChoice<string> { Choice = a.Type.Name, DisplayString = a.Type.Name })));
if (answer.Choice != NoRename) {
// rename the table
var renameFrom = removed;
var renameTo = additions.First(a => a.Type.Name == answer.Choice);
sql.AppendSql(this.alterTableWriter.RenameTable(renameFrom, renameTo));
// add to the matches
matches.Add(MigrationPair.Of(renameFrom, renameTo));
// modify additions and removals
removals.Remove(renameFrom);
additions.Remove(renameTo);
// sort out the primary key
var fromPrimaryKey = renameFrom.PrimaryKey;
var toPrimaryKey = renameTo.PrimaryKey;
if (!AreColumnDefinitionsEqual(fromPrimaryKey, toPrimaryKey)) {
if (fromPrimaryKey.DbName != toPrimaryKey.DbName && fromPrimaryKey.DbType == toPrimaryKey.DbType
&& (!fromPrimaryKey.DbType.TypeTakesLength() || (fromPrimaryKey.MaxLength && toPrimaryKey.MaxLength)
|| (fromPrimaryKey.Length == toPrimaryKey.Length))
&& (!fromPrimaryKey.DbType.TypeTakesPrecisionAndScale()
|| (fromPrimaryKey.Precision == toPrimaryKey.Precision && fromPrimaryKey.Scale == toPrimaryKey.Scale))) {
// just a change in name
sql.AppendSql(this.alterTableWriter.ChangeColumnName(fromPrimaryKey, toPrimaryKey));
}
else {
// ask the question
// TODO may things more sensible based on the type
var attemptChange =
answerProvider.GetBooleanAnswer(
"The primary key change required for this table rename involves a change "
+ (fromPrimaryKey.DbType != toPrimaryKey.DbType ? "of data type" : "of specification")
+ ". Would you like to attempt the change? (Selecting No will drop and re-create the column)");
if (attemptChange) {
if (fromPrimaryKey.DbName != toPrimaryKey.DbName) {
sql.AppendSql(this.alterTableWriter.ChangeColumnName(fromPrimaryKey, toPrimaryKey));
}
sql.AppendSql(this.alterTableWriter.ModifyColumn(fromPrimaryKey, toPrimaryKey));
renamePrimaryKeyModifications.Add(Tuple.Create(fromPrimaryKey.Map.Type.Name, toPrimaryKey.Map.Type.Name), true);
}
else {
// drop and re-create
sql.AppendSql(this.alterTableWriter.DropColumn(fromPrimaryKey));
sql.AppendSql(this.alterTableWriter.AddColumn(toPrimaryKey));
renamePrimaryKeyModifications.Add(Tuple.Create(fromPrimaryKey.Map.Type.Name, toPrimaryKey.Map.Type.Name), false);
}
}
}
//.........这里部分代码省略.........
示例14: InternalMethodTracer
public InternalMethodTracer(string methodName, ILogger logger)
{
if (string.IsNullOrEmpty(methodName))
{
throw new ArgumentException("methodName was null or empty", "methodName");
}
if (logger == null)
{
throw new ArgumentNullException("logger");
}
m_logger = logger;
m_methodName = methodName;
m_logger.Trace(methodName + MethodBeginSuffix);
}
示例15: Cache
private void Cache(Type resourceType, Map data, ILogger logger)
{
string href = data[AbstractResource.HrefPropertyName].ToString();
var cacheData = new Dictionary<string, object>();
bool isCustomData = resourceType == typeof(ICustomData);
if (isCustomData)
{
logger.Trace($"Response {href} is a custom data resource, caching directly", "WriteCacheFilter.Cache");
var cache = this.GetSyncCache(resourceType);
cache.Put(this.GetCacheKey(href), data);
return; // simple! return early
}
bool isCacheable = true;
foreach (var item in data)
{
string key = item.Key;
object value = item.Value;
// TODO DefaultModelMap edge case
// TODO ApiEncryptionMetadata edge case
var asNestedResource = value as ExpandedProperty;
var asNestedMapArray = value as IEnumerable<Map>;
var asNestedScalarArray = value as IEnumerable<object>;
if (asNestedResource != null && IsResource(asNestedResource.Data))
{
logger.Trace($"Attribute {key} on response {href} is an expanded resource, caching recursively", "WriteCacheFilter.Cache");
var nestedType = this.typeLookup.GetInterfaceByPropertyName(item.Key);
if (nestedType == null)
{
logger.Warn($"Cannot cache nested item. Item type for '{key}' unknown. '{href}' will not be cached.");
isCacheable = false; // gracefully disable caching
break;
}
this.Cache(nestedType, asNestedResource.Data, logger);
value = ToCanonicalReference(key, asNestedResource.Data);
}
else if (asNestedMapArray != null)
{
logger.Trace($"Attribute {key} on response {href} is an array, caching items recursively", "WriteCacheFilter.CacheAsync");
var nestedType = this.typeLookup.GetInnerCollectionInterface(resourceType);
if (nestedType == null)
{
logger.Warn($"Can not cache array '{key}'. Item type for '{resourceType.Name}' unknown. '{href}' will not be cached.");
isCacheable = false; // gracefully disable caching
break;
}
// This is a CollectionResponsePage<T>.Items property.
// Recursively cache nested resources and create a new collection that only has references
var canonicalList = new List<object>();
foreach (var element in asNestedMapArray)
{
object canonicalElement = element;
var resourceElement = canonicalElement as Map;
if (resourceElement != null)
{
if (IsResource(resourceElement))
{
this.Cache(nestedType, resourceElement, logger);
canonicalElement = ToCanonicalReference(key, resourceElement);
}
}
canonicalList.Add(canonicalElement);
}
value = canonicalList;
}
else if (asNestedScalarArray != null)
{
var nestedType = this.typeLookup.GetInterfaceByPropertyName(key);
if (nestedType == null)
{
logger.Warn($"Can not cache array '{key}'. Item type for '{resourceType.Name}' unknown. '{href}' will not be cached.");
isCacheable = false; // gracefully disable caching
break;
}
// This is an array of primitives, such as string[].
// (Not currently supported. Will be supported in the future.)
logger.Warn($"Can not cache array '{key}'. Array caching is currently unsupported. '{href}' will not be cached.");
isCacheable = false; // gracefully disable caching
break;
}
if (!IsSensitive(key))
{
cacheData.Add(key, value);
}
}
//.........这里部分代码省略.........