public static string ToCategoryString(this ActivityLogLevel activityLogLevel) { const string otherStr = "Other"; const string categorySuffix = "XX"; switch (activityLogLevel) { case ActivityLogLevel.Debug: case ActivityLogLevel.Information: case ActivityLogLevel.Critical: return(activityLogLevel.ToString()); } int logLevelInt = (int)activityLogLevel; if ((logLevelInt - (int)ActivityLogLevel.Debug) < 10) { return(ActivityLogLevel.Debug.ToString() + categorySuffix); } if ((logLevelInt - (int)ActivityLogLevel.Information) < 10) { return(ActivityLogLevel.Information.ToString() + categorySuffix); } if ((logLevelInt - (int)ActivityLogLevel.Critical) < 10) { return(ActivityLogLevel.Critical.ToString() + categorySuffix); } return(otherStr); }
public Activity StartNewActivity(string activityName, ActivityLogLevel logLevel) { activityName = ValidateActivityName(activityName); string parentOperationId, globalOperationId; TryGetDistributedTracingContext(out parentOperationId, out globalOperationId); LogicalExecutionStack currentLogicalStack = GetOrCreateCurrentLogicalStack(); lock (currentLogicalStack) { Activity parent = currentLogicalStack.Peek(); // may be null var activity = new Activity( activityName, logLevel, Util.CreateRandomId(), parent?.RootActivity, parent, parentOperationId, globalOperationId, currentLogicalStack); currentLogicalStack.Push(activity); return(activity); } }
private void Log(ActivityLogLevel level, string msg) { if (ActivityLog != null) { ActivityLog(level, msg); } }
internal Activity( string activityName, ActivityLogLevel logLevel, string activityId, Activity root, Activity parent, string distributedTracingParentOperationId, string distributedTracingGlobalOperationId, LogicalExecutionStack logicalExecutionStack) { this.LogicalExecutionStack = Util.EnsureNotNull(logicalExecutionStack, nameof(logicalExecutionStack)); this.Name = Util.EnsureNotNullOrEmpty(activityName, nameof(activityName)); this.LogLevel = logLevel; this.Status = ActivityStatus.Running; this.ActivityId = Util.EnsureNotNullOrEmpty(activityId, nameof(activityId)); this.RootActivity = root ?? this; this.ParentActivity = parent; this.DistributedTracingParentOperationId = distributedTracingParentOperationId; // may be null this.DistributedTracingGlobalOperationId = distributedTracingGlobalOperationId; // may be null this.StartTime = DateTimeOffset.Now; this.EndTime = default(DateTimeOffset); this.FaultException = null; this.FaultMessage = null; this.InitialFaultActivity = null; this.FaultId = null; }
//===================================================================== #region Privates Static methods. /// <summary> /// To trace the activity of the messenger, useful to debug. /// </summary> /// <param name="level"></param> /// <param name="msg"></param> private static void Messenger_ActivityLog(ActivityLogLevel level, string msg) { if (level == ActivityLogLevel.Debug) { logger.Debug(msg); } else if (level == ActivityLogLevel.Error) { logger.Error(msg); } }
public void LogFormat(ActivityLogLevel activityLogLevel, string format, params object[] args) { if (activityLogLevel <= logLevel) { if (activityLogLevel == ActivityLogLevel.Warning) { format = "WARNING: " + format; } else if (activityLogLevel == ActivityLogLevel.Error) { format = "ERROR: " + format; } System.Console.Out.WriteLine(format, args); } }
public Activity StartNewActivityWithOperation <TOperation>( string name, ActivityLogLevel logLevel, string operationId = null, string parentOperationId = null, string globalOperationId = null) where TOperation : OperationTelemetry, new() { name = ValidateActivityName(name); ApplicationInsightsActivitySender appInsightsSender = FindApplicationInsightsSender(); IDisposable operation = appInsightsSender?.StartActivityOperation <TOperation>(name, operationId, parentOperationId, globalOperationId); Activity activity = StartNewActivity(name, logLevel); activity.AssociatedOperation = operation; return(activity); }
public ActivityLogEntity AddLog(string descriminator, ActivityLogLevel level = ActivityLogLevel.Info, string message = null, IClassifiable classifiable = null, object contract = null) { var entry = new ActivityLogEntity(); entry.Descriminator = descriminator; entry.Message = message; entry.Level = level; if(contract!=null)entry.SetValue(contract); if (classifiable != null) { entry.ClassifiableId = classifiable.Id; entry.ClassifiableName = classifiable.ObjectName; } entry = logRepo.Save(entry); InvokeOnNewLog(entry); return entry; }
public Activity StartNewLogicalActivityThread(string activityName, ActivityLogLevel logLevel) { activityName = ValidateActivityName(activityName); string parentOperationId, globalOperationId; TryGetDistributedTracingContext(out parentOperationId, out globalOperationId); LogicalExecutionStack currentLogicalStack = _logicalExecutionThread.Value; object lockScope = currentLogicalStack; lockScope = lockScope ?? _logicalExecutionThread; lock (lockScope) { Activity parent = currentLogicalStack?.Peek(); // may be null var newLogicalStack = new LogicalExecutionStack(currentLogicalStack); var activity = new Activity( activityName, logLevel, Util.CreateRandomId(), parent?.RootActivity, parent, parentOperationId, globalOperationId, newLogicalStack); newLogicalStack.Push(activity); _logicalExecutionThread.Value = newLogicalStack; return(activity); } }
public ActivityLogEntity AddLog(string descriminator, ActivityLogLevel level = ActivityLogLevel.Info, string message = null, IClassifiable classifiable = null, object contract = null) { var entry = new ActivityLogEntity(); entry.Descriminator = descriminator; entry.Message = message; entry.Level = level; if (contract != null) { entry.SetValue(contract); } if (classifiable != null) { entry.ClassifiableId = classifiable.Id; entry.ClassifiableName = classifiable.ObjectName; } entry = logRepo.Save(entry); InvokeOnNewLog(entry); return(entry); }
public Activity StartNewActivity(string activityNamePrefix, string activityNamePostfix, ActivityLogLevel logLevel) { string activityName = ConstructActivityName(activityNamePrefix, activityNamePostfix); return(StartNewActivity(activityName, logLevel)); }
public ActivitySelectorByLogLevel(ActivityLogLevel logLevel) { _logLevel = logLevel; }
public static Func <Activity, bool> Larger(ActivityLogLevel logLevel) { return((new ActivitySelectorByLogLevel(logLevel)).IsLarger); }
public static Func <Activity, bool> Equal(ActivityLogLevel logLevel) { return((new ActivitySelectorByLogLevel(logLevel)).IsEqual); }
public void Log(ActivityLogLevel activityLogLevel, string message) { LogFormat(activityLogLevel, "{0}", message); }