Ejemplo n.º 1
0
        public void Warn_Valid_Fact()
        {
            _wrapper.Warn("This is a Fact");

            _eventArgs.Should().NotBeNull();
            _eventArgs.Name.Should().Be("This is a Fact");
            _eventArgs.Level.Should().Be(LogLevel.Warn);
        }
Ejemplo n.º 2
0
        private void AddLog(string Msg, StackTrace stack = null, string Tittle = "", int TenantId = 0, int UserId = 0, LogType logtype = LogType.Debug, Object Context = null)
        {
            try
            {
                if (stack == null)
                {
                    stack = new StackTrace(true);
                }
                var    methodBase = stack.GetFrame(1).GetMethod();
                Type   stacktype  = methodBase.DeclaringType;
                string fileName   = stacktype.FullName; //文件名
                string methodName = methodBase.Name;    //方法名
                var    logModel   = new LogModel
                {
                    TenantId   = TenantId,
                    UserId     = UserId,
                    Message    = Msg,
                    Title      = Tittle,
                    MethodName = methodName,
                    FileName   = fileName,
                    CodeLine   = "0"
                };
                var jsonValue = JsonConvert.SerializeObject(logModel);
                switch (logtype)
                {
                case LogType.Debug:
                    _log.Debug(jsonValue);
                    break;

                case LogType.Info:
                    _log.Info(jsonValue);
                    break;

                case LogType.Warn:
                    _log.Warn(jsonValue);
                    break;

                case LogType.Error:
                    _log.Error(jsonValue);
                    break;

                case LogType.Fatal:
                    _log.Fatal(jsonValue);
                    break;

                default:
                    _log.Debug(jsonValue);
                    break;
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// This will set the perf counter to a cretain value
 /// </summary>
 /// <param name="counterItem">counter item</param>
 /// <param name="counterValue">counter value</param>
 public void SetCounterValue(BerkeleyBinaryStorePerformanceCounterEnum counterItem, int counterValue)
 {
     if (this.CounterArray != null)
     {
         this.CounterArray.counters[(int)counterItem].RawValue = counterValue;
     }
     else
     {
         if (Log.IsWarnEnabled)
         {
             Log.Warn(string.Format("The Counter instance {0} is null, can not be set", this.perfCounterInstanceName));
         }
     }
 }
Ejemplo n.º 4
0
        private static EnvironmentMappingsConfig GetConfig()
        {
            var config = EnvironmentMappingsConfig.GetConfig();

            if (config == null)
            {
                _log.Warn("No Config found");
            }
            return(config);
        }
Ejemplo n.º 5
0
        private void InitializeInstance(TypeSettingCollection typeSettingCollection)
        {
            if (typeSettingCollection == null)
            {
                _log.Warn("TypeSpecificStatisticsManager:InitializeInstance " +
                          "typeSettingCollection is null.");
                return;
            }

            //set up status collection with max size and whether each element should collect stats
            _typeSettingStatusCollection = new TypeSettingStatus[typeSettingCollection.MaxTypeId + 1];
            foreach (var setting in typeSettingCollection)
            {
                _typeSettingStatusCollection[setting.TypeId] = new TypeSettingStatus();
                _typeSettingStatusCollection[setting.TypeId].Update(setting);
            }

            //Add status for typeId Zero (DeleteAllTypes) which is not specific to a group
            //or specified in RelayTypeSettings configuration
            TypeSetting zeroTypeSetting = CreateZeroTypeSetting();

            _typeSettingStatusCollection[0] = new TypeSettingStatus();
            _typeSettingStatusCollection[0].Update(zeroTypeSetting);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// get a DbConnection Instance
        /// </summary>
        /// <param name="database"></param>
        /// <returns></returns>
        public static System.Data.IDbConnection GetConn(string database)
        {
            OrmLiteConnectionFactory factory = OrmLiteConnectionManager.Instance[database];

            if (factory == null)
            {
                throw new ArgumentException(string.Format("cannt get connection for database:{0}", database));
            }

            var conn = factory.Open();

            TotalOpenedConnection++;
            if (TotalOpenedConnection > 100)
            {
                log.Warn(string.Format("Current opend DbConnection count >={0}", TotalOpenedConnection));
            }
            return(conn);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 警告
 /// </summary>
 /// <param name="message"></param>
 public static void Warn(string message)
 {
     _log.Warn(message);
 }