Exemplo n.º 1
0
 private static void ClearLogLevels(LoggingRule loggingRule)
 {
     foreach (var logLevel in LogLevels)
     {
         if (logLevel != LogLevel.Off && loggingRule.IsLoggingEnabledForLevel(logLevel))
         {
             loggingRule.DisableLoggingForLevel(logLevel);
         }
     }
 }
Exemplo n.º 2
0
        public TimeMeasurer(string message, bool logStartMessage = false, LogLevel level = null)
        {
            _level = level ?? LogLevel.Debug;

            LoggingRule rule = LogManager.Configuration.LoggingRules.FirstOrDefault();

            _isEnabled = rule != null && rule.IsLoggingEnabledForLevel(_level);

            if (_isEnabled)
            {
                _message = message;

                if (logStartMessage)
                {
                    string s = string.Format("BEGIN:{0}", _message);
                    Log(s);
                }

                _stopwatch = new Stopwatch();
                _stopwatch.Start();
            }
        }
Exemplo n.º 3
0
        public TimeMeasurer(string message, bool logStartMessage = false, LogLevel level = null)
        {
            _level = level ?? LogLevel.Trace;

            LoggingRule rule = LogManager.Configuration?.LoggingRules.FirstOrDefault();

            _isEnabled = rule != null && rule.IsLoggingEnabledForLevel(_level);

            if (_isEnabled)
            {
                _message = message;

                if (logStartMessage)
                {
                    string s = $"Begin {_message}";
                    Log(s);
                }

                _stopwatch = new Stopwatch();
                _stopwatch.Start();
            }
        }