Ejemplo n.º 1
0
 public static void Debug(LogGroups group, string message)
 {
     if ((_logLevel == LogLevel.DebugWarningsAndErrors || _logLevel == LogLevel.All) && IsGroupEnabled(group))
     {
         _logger.Debug(FormatMessage(group, message));
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 检测是否继续
        /// </summary>
        /// <returns></returns>
        protected override bool CheckContinue()
        {
            ComputeNextFireTime();

            if (NextFireTime == null || !NextFireTime.HasValue)
            {
                _logProvider.Debug(string.Format(CultureInfo.InvariantCulture, @"Is Continue : {0}", "False"));
                return(false);
            }

            _logProvider.Debug(string.Format(CultureInfo.InvariantCulture, @"Is Continue : {0}", "True"));
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Logs to internal.
        /// </summary>
        /// <param name="level">The level.</param>
        /// <param name="message">The message.</param>
        /// <param name="provider">The provider.</param>
        /// <param name="category">The category.</param>
        /// <exception cref="ArgumentOutOfRangeException">level - null</exception>
        private static void LogToInternal(LogLevel level, string message, ILogProvider provider, string category)
        {
            switch (level)
            {
            case LogLevel.FATAL:
                provider.Fatal(category, message);
                break;

            case LogLevel.ERROR:
                provider.Error(category, message);
                break;

            case LogLevel.WARNING:
                provider.Warning(category, message);
                break;

            case LogLevel.INFO:
                provider.Info(category, message);
                break;

            case LogLevel.TRACE:
                provider.Trace(category, message);
                break;

            case LogLevel.DEBUG:
                provider.Debug(category, message);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(level), level, null);
            }
        }
Ejemplo n.º 4
0
 public static void CallMe()
 {
     for (int i = 1; i <= 5; i++)
     {
         log.Info($"{i} - Info text");
         log.Debug($"{i} - Debug text");
         log.Warning($"{i} - Warning text");
         log.Error($"{i} - Error text");
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 检测触发时间
        /// </summary>
        /// <returns></returns>
        protected override bool CheckFireTime()
        {
            if (FireTime.HasValue)
            {
                _logProvider.Debug(string.Format(CultureInfo.InvariantCulture, @"Next Fire Time : {0}",
                                                 FireTime.Value.ToString(Constants.DateTimeFormat, CultureInfo.InvariantCulture)));
                if (DateTime.Now >= FireTime.Value)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 通过实现此方法来拦截调用并执行所需的拦截行为。
        /// </summary>
        /// <param name="input">调用拦截目标时的输入信息。</param>
        /// <param name="getNext">通过行为链来获取下一个拦截行为的委托。</param>
        /// <returns>从拦截目标获得的返回信息。</returns>
        public IMethodReturn Invoke(IMethodInvocation input, GetNextInterceptionBehaviorDelegate getNext)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            if (getNext == null)
            {
                throw new ArgumentNullException("getNext");
            }

            //执行验证操作;
            var tempMethod = input.MethodBase as System.Reflection.MethodInfo;

            var inputParameterCollection = input.Inputs;

            var tempLogAttributes = tempMethod.GetCustomAttributes(typeof(LogAttribute));

            if (tempLogAttributes.Count() == 0)
            {
                return(getNext().Invoke(input, getNext));
            }

            //根据反射获取对象的成员信息
            var realArguments = (object[])ReflectHelper.GetInstanceProperty(inputParameterCollection, "arguments");

            if (inputParameterCollection.Count == 0)
            {
                return(getNext().Invoke(input, getNext));
            }

            //计时器开始 监视方法执行时间---Debug模式下启用

            //开始监视
            //计时器
#if DEBUG
            var stopwatch        = Stopwatch.StartNew();
            var tempReturnResult = getNext().Invoke(input, getNext);
            stopwatch.Stop();
            var totalMillisencodes = stopwatch.Elapsed.TotalMilliseconds;
#else
            var tempReturnResult = getNext().Invoke(input, getNext);
#endif
            //生成日志对象
            var logInfo = string.Format("TODO....");
            //输出到log---采用异步方式
            ILogProvider logProvider = ObjectContainer.CreateInstance <ILogProvider>();
            logProvider.Debug(logInfo);
            return(tempReturnResult);
        }
Ejemplo n.º 7
0
 public static void Debug(string errMsg, Exception ex)
 {
     CheckLogProviderNotNull();
     staticLogProvider.Debug(errMsg, ex);
 }
Ejemplo n.º 8
0
 public void Debug(string message)
 {
     _provider.Debug(message);
 }
Ejemplo n.º 9
0
 public void Debug(string message)
 {
     _log.Debug(message);
 }