Пример #1
0
        public static bool SetCurrentContextDetails(LoggingContextDetails contextDetails)
        {
            string currContextId = GetCurrentContextId();

            if (currContextId == null)
            {
                return(false);
            }

            AddContext(currContextId, contextDetails, true);

            return(true);
        }
Пример #2
0
        private void SetLoggingContext(object[] inputs, MethodInfo mi)
        {
            LoggingContextDetails lcd = new LoggingContextDetails
            {
                MethodDetails   = mi,
                Inputs          = inputs,
                LoggingStrategy = LoggingStrategy,
                LogErrors       = LogErrors,
                LogWarnings     = LogWarnings,
                LogInformation  = LogInformation
            };

            LoggingContext.SetCurrentContextDetails(lcd);
        }
Пример #3
0
        protected static void AddContext(string id,
                                         LoggingContextDetails contextDetails,
                                         bool replaceIfExist)
        {
            if (id == null)
            {
                return;
            }

            lock (Contexts)
            {
                if (replaceIfExist && Contexts.ContainsKey(id))
                {
                    Contexts.Remove(id);
                }

                if (!Contexts.ContainsKey(id) && contextDetails != null)
                {
                    Contexts.Add(id, contextDetails);
                }
            }
        }