コード例 #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);
                }
            }
        }