Ejemplo n.º 1
0
        public dynamic GetLogOnOff(int appId = 0)
        {
            string resp = string.Empty;

            var on_off = LogViewerManager.GetLogViewer().GetLogOnOff(appId);

            if (on_off != null)
            {
                resp += on_off.Debug + "," + on_off.Info + "," + on_off.Warn + "," + on_off.Error;
            }

            #region 计数

            TMetricEntity metric = new TMetricEntity();
            metric.Name  = "logging_client_getLogOnOff_count";
            metric.Time  = Utils.GetTimeStamp(DateTime.Now) / 10000000;
            metric.Value = 1;
            metric.Tags  = new Dictionary <string, string>();
            metric.Tags.Add("AppId", appId.ToString());
            List <TMetricEntity> metrics = new List <TMetricEntity>();
            metrics.Add(metric);

            TLogPackage logPackage = new TLogPackage();
            logPackage.AppId       = appId;
            logPackage.IP          = 0;
            logPackage.MetricItems = metrics;

            LogReciverBase LogReciver = new LogReciverBase();

            LogReciver.Log(logPackage);

            #endregion 计数

            return(resp);
        }
Ejemplo n.º 2
0
        protected TLogPackage CreateLogPackage(IList <ILogEntity> logEntities)
        {
            var logs    = logEntities.Where(x => x.Type == 1);
            var metrics = logEntities.Where(x => x.Type == 2);

            List <TLogEntity> tlogs = new List <TLogEntity>();

            foreach (var log in logs)
            {
                var        _log = log as LogEntity;
                TLogEntity tlog = new TLogEntity();
                tlog.Level   = (sbyte)_log.Level;
                tlog.Message = _log.Message;
                tlog.Source  = _log.Source;
                tlog.Tags    = _log.Tags;
                tlog.Thread  = _log.Thread;
                tlog.Time    = _log.Time;
                tlog.Title   = _log.Title;
                tlogs.Add(tlog);
            }

            List <TMetricEntity> tmetrics = new List <TMetricEntity>();

            foreach (var metric in metrics)
            {
                var           _metric = metric as MetricEntity;
                TMetricEntity tmetric = new TMetricEntity();
                tmetric.Name  = _metric.Name;
                tmetric.Tags  = _metric.Tags;
                tmetric.Time  = _metric.Time;
                tmetric.Value = _metric.Value;
                tmetrics.Add(tmetric);
            }

            TLogPackage package = new TLogPackage();

            package.AppId       = Settings.AppId;
            package.IP          = ServerIPNum;
            package.LogItems    = tlogs;
            package.MetricItems = tmetrics;
            return(package);
        }
Ejemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            int appId = Convert.ToInt32(context.Request["appId"]);

            string resp = string.Empty;


            var on_off = LogViewerManager.GetLogViewer().GetLogOnOff(appId);

            if (on_off != null)
            {
                resp += on_off.Debug + "," + on_off.Info + "," + on_off.Warn + "," + on_off.Error;
            }

            #region 计数
            TMetricEntity metric = new TMetricEntity();
            metric.Name  = "logging_client_getLogOnOff_count";
            metric.Time  = Utils.GetTimeStamp(DateTime.Now) / 10000000;
            metric.Value = 1;
            metric.Tags  = new Dictionary <string, string>();
            metric.Tags.Add("AppId", appId.ToString());
            List <TMetricEntity> metrics = new List <TMetricEntity>();
            metrics.Add(metric);


            TLogPackage logPackage = new TLogPackage();
            logPackage.AppId       = appId;
            logPackage.IP          = 0;
            logPackage.MetricItems = metrics;

            LogReciverBase LogReciver = new LogReciverBase();

            LogReciver.Log(logPackage);


            #endregion

            context.Response.Write(resp);
        }