Exemple #1
0
        public async Task LogForUser(string userId, string message, DigitTraceAction action = DigitTraceAction.Default, IDictionary <string, object> additionalData = null, LogLevel logLevel = LogLevel.Information)
        {
            var telemetry = new TraceTelemetry(message, FromLogLevel(logLevel));

            if (null != additionalData)
            {
                foreach (var prop in additionalData)
                {
                    telemetry.Properties.Add(prop.Key, prop.Value.ToString());
                }
            }
            telemetry.Properties.Add("digitTraceAction", action.ToString());
            telemetry.Context.User.Id = userId;
            string id = Guid.NewGuid().ToString();

            telemetry.Properties.Add("digitTraceId", id);
            _telemetryClient.TrackTrace(telemetry);
            var e = new LogEntry()
            {
                UserId           = userId,
                AdditionalData   = telemetry.Properties,
                Author           = "digit-svc",
                DigitTraceAction = action,
                FocusItemId      = telemetry.Properties.ContainsKey("focusItemId") ? telemetry.Properties["focusItemId"] : null,
                Id        = id,
                LogLevel  = logLevel,
                Message   = message,
                Timestamp = DateTimeOffset.Now
            };
            await Task.WhenAll(_subscribers.Select(s => s.Add(e)));
        }
Exemple #2
0
 public static Task LogErrorForUser(this IDigitLogger digitLogger, string userId, string message,
                                    DigitTraceAction action = DigitTraceAction.Default,
                                    IDictionary <string, object> additionalData = null)
 {
     return(digitLogger.LogForUser(userId, message, action, additionalData, LogLevel.Error));
 }
Exemple #3
0
 public async Task LogForFocusItem(string userId, string focusItemId, string message, DigitTraceAction action = DigitTraceAction.Default, IDictionary <string, object> additionalData = null, LogLevel logLevel = LogLevel.Information)
 {
     if (null == additionalData)
     {
         additionalData = new Dictionary <string, object>();
     }
     additionalData.Add("focusItemId", focusItemId);
     await LogForUser(userId, message, action, additionalData, logLevel);
 }