Exemple #1
0
 public void WriteLine(ImportanceLevel importance, string format, params object[] segments)
 {
     if (importance >= this.importance)
     {
         Console.WriteLine("[{0}]:\t{1}", importance, string.Format(format, segments));
     }
 }
Exemple #2
0
        public static string GetCssClass(ImportanceLevel imp, bool withpreDash)
        {
            string res = "";

            if (withpreDash)
            {
                res = "-";
            }

            switch (imp)
            {
            case ImportanceLevel.Formal:
                return(string.Empty);

            case ImportanceLevel.Minor:
                return(res + "info");

            case ImportanceLevel.Major:
                return(res + "warning");

            case ImportanceLevel.Fatal:
                return(res + "danger");

            case ImportanceLevel.NeedHumanReview:
            default:
                return(string.Empty);
            }
        }
Exemple #3
0
 public ActivationThreshold(
     ImportanceLevel metricThreshold,
     LogEventLevel textualThreshold)
 {
     Metric  = metricThreshold;
     Textual = textualThreshold;
 }
 public ActivationItem(
     ImportanceLevel metricThreshold,
     LogEventLevel textualThreshold,
     IEnumerable <ActivationFilter> filters)
 {
     Threshold = new ActivationThreshold(metricThreshold, textualThreshold);
     Filters   = filters?.ToArray() ?? Array.Empty <ActivationFilter>();
 }
 public ActivationExtend(
     ImportanceLevel importance,
     string componentTag,
     IEnumerable <ActivationFilter> filters)
 {
     Importance = importance;
     Filters    = filters?.ToArray() ?? Array.Empty <ActivationFilter>();
 }
 public ActivationSetting(
     ImportanceLevel metricThreshold,
     LogEventLevel textualThreshold,
     IEnumerable <ActivationItem> constricts,
     IEnumerable <ActivationItem> extends)
     : base(/*metricThreshold, textualThreshold, */ constricts, extends)
 {
     Threshold = new ActivationThreshold(metricThreshold, textualThreshold);
 }
Exemple #7
0
 public ActivationSetting(
     ImportanceLevel minImportance,
     IEnumerable <ActivationConstrict> constricts,
     IEnumerable <ActivationExtend> extends)
 {
     MinImportance = minImportance;
     Constricts    = constricts?.ToArray() ?? Array.Empty <ActivationConstrict>();
     Extends       = extends?.ToArray() ?? Array.Empty <ActivationExtend>();
 }
Exemple #8
0
        public static void StartBlock(string line, ImportanceLevel importance = ImportanceLevel.Debug)
        {
            if (importance < MinimalImportanceLevel)
            {
                NestingLevel++;
                return;
            }

            Debug.WriteLine("┃".Repeat(++NestingLevel - 1) + $"┏{line}");
        }
Exemple #9
0
        public static void FinishBlock(string line, ImportanceLevel importance = ImportanceLevel.Debug)
        {
            if (importance < MinimalImportanceLevel)
            {
                NestingLevel--;
                return;
            }

            Debug.WriteLine("┃".Repeat(NestingLevel-- - 1) + $"┗{line}");
        }
Exemple #10
0
        public Logger(ImportanceLevel il, string fileName)
        {
            working      = true;
            importance   = il;
            log          = new Thread(new ThreadStart(LogMessage));
            log.Priority = ThreadPriority.Lowest;
            //log.Start();

            this.fileName = fileName;
            WriteLine(ImportanceLevel.Warning, "Logger started");
        }
Exemple #11
0
    private void Alarm(ImportanceLevel _level)
    {
        //显示出新的任务:假如上个任务完成,则只显示开始、跳过;假如上个任务未完成,则显示完成、终止,然后再显示开始和跳过

        //震动提示
        switch (_level)
        {
        case ImportanceLevel.Soft:
            Debug.Log(taskList[curTaskIndex].TaskString);
            break;
        }
    }
 /// <summary>
 /// Counts the specified importance.
 /// </summary>
 /// <param name="importance">The importance.</param>
 /// <param name="tags">The tags.</param>
 /// <param name="count">The count.</param>
 public void Count(
     ImportanceLevel importance,
     IReadOnlyDictionary <string, string> tags,
     int count)
 {
     if (_activation.IsActive(importance))
     {
         tags = _tags.AddRange(tags ?? ImmutableDictionary <string, string> .Empty)
                .AddRange(_tagContext.Tags ?? ImmutableDictionary <string, string> .Empty);
         _influxClient.Increment(_measurementName, count, tags: tags);
     }
 }
        /// <summary>
        /// Reports the specified fields.
        /// </summary>
        /// <param name="fields">The fields.</param>
        /// <param name="tags">The tags.</param>
        /// <param name="importance">The importance.</param>
        public void Report(
            IReadOnlyDictionary <string, object> fields,
            IReadOnlyDictionary <string, string> tags,
            ImportanceLevel importance)
        {
            if (_activation.IsActive(importance))
            {
                var contextTags =
                    tags = _tags.AddRange(tags ?? ImmutableDictionary <string, string> .Empty)
                           .AddRange(_tagContext.Tags ?? ImmutableDictionary <string, string> .Empty);

                _influxClient.Write(_measurementName, fields, tags);
            }
        }
        /// <summary>
        /// Report operation duration.
        /// </summary>
        /// <param name="importance">The importance.</param>
        /// <param name="tags">The tags.</param>
        /// <returns></returns>
        public IDisposable Duration(
            ImportanceLevel importance,
            IReadOnlyDictionary <string, string> tags)
        {
            IDisposable result = NonDisposable.Default;

            if (_activation.IsActive(importance))
            {
                tags = _tags.AddRange(tags ?? ImmutableDictionary <string, string> .Empty)
                       .AddRange(_tagContext.Tags ?? ImmutableDictionary <string, string> .Empty);

                result = _influxClient.Time(_measurementName, tags: tags);
            }
            return(result);
        }
Exemple #15
0
        public static void Log(string line, ImportanceLevel importance = ImportanceLevel.Debug)
        {
            if (importance < MinimalImportanceLevel)
            {
                return;
            }

            if (NestingLevel == 0)
            {
                Debug.WriteLine(line);
            }
            else
            {
                Debug.WriteLine("┃".Repeat(NestingLevel - 1) + $"┣[{importance}]{line}");
            }
        }
        /// <summary>
        /// Determines whether the specified metric level is active.
        /// </summary>
        /// <param name="metricLevel">The metric level.</param>
        /// <returns>
        ///   <c>true</c> if the specified metric level is active; otherwise, <c>false</c>.
        /// </returns>
        public bool IsActive(
            ImportanceLevel metricLevel)
        {
            if (metricLevel < _setting.MinImportance)
            {
                #region Check if pass the extends

                foreach (var extend in _setting.Extends)
                {
                    var settingImportance = extend.Importance;
                    if (settingImportance > metricLevel)
                    {
                        continue; // won't activate anyway
                    }
                    var tokenSupportAllFilters =
                        extend.Filters.All(m => _activationContext.HasToken(m.Path));
                    if (tokenSupportAllFilters)
                    {
                        return(true); // both important and filters match
                    }
                }
                return(false);

                #endregion // If(Extend) true
            }

            #region Check if constricted

            foreach (var constrict in _setting.Constricts)
            {
                var settingImportance = constrict.Importance;
                if (settingImportance < metricLevel)
                {
                    continue; // activate anyway
                }
                var tokenSupportAllFilters =
                    constrict.Filters.All(m => _activationContext.HasToken(m.Path));
                if (tokenSupportAllFilters)
                {
                    return(false); // both important and filters match
                }
            }

            #endregion // Check if constricted
            return(true);
        }
Exemple #17
0
        public void ShowMessage(ImportanceLevel level, string message, string title = null)
        {
            switch (level)
            {
            case ImportanceLevel.Error:
                MessageDialogHelper.RunErrorDialog(message, title);
                break;

            case ImportanceLevel.Warning:
                MessageDialogHelper.RunWarningDialog(message, title);
                break;

            case ImportanceLevel.Info:
            default:
                MessageDialogHelper.RunInfoDialog(message, title);
                break;
            }
        }
        public void ShowMessage(ImportanceLevel level, string message, string title = null)
        {
            switch (level)
            {
            case ImportanceLevel.Info:
                logger.Info(message);
                break;

            case ImportanceLevel.Warning:
                logger.Warn(message);
                break;

            case ImportanceLevel.Error:
                logger.Error(message);
                break;

            default:
                break;
            }
        }
Exemple #19
0
        public static string IssuesByLevelQuery(ImportanceLevel importanceLevel)
        {
            List <string> sb      = new List <string>();
            string        logical = " OR ";
            string        key     = "issues.issueTypeId:{0}";

            foreach (int iss in Enum.GetValues(typeof(Issues.IssueType.IssueTypes)))
            {
                if (IssueType.IssueImportance(iss) == importanceLevel)
                {
                    sb.Add(string.Format(key, iss));
                }
            }

            if (sb.Count == 0)
            {
                return(string.Empty);
            }
            else
            {
                return("( " + sb.Aggregate((f, s) => f + logical + s) + " )");
            }
        }
 public void ShowMessage(ImportanceLevel level, string message, string title = null)
 {
     interactiveMessage.ShowMessage(ImportanceLevel.Info, message, title);
 }
Exemple #21
0
 /// <summary>
 /// Determines whether the specified metric level is active.
 /// </summary>
 /// <param name="level">The metric level.</param>
 /// <returns>
 ///   <c>true</c> if the specified metric level is active; otherwise, <c>false</c>.
 /// </returns>
 public bool IsActive(
     ImportanceLevel level)
 {
     return(IsActive((int)level, TelemetryActivationKind.Metric));
 }
        }  //DataBase-den Userleri Statusuna uygun filtirlemeq ve List qaytarmaq

        public List <TodoEntity> GetAll(ImportanceLevel importanceLevel)
        {
            return(_todoDal.GetAll(importanceLevel));
        }   //DataBase-den Userleri ImportanceLevel uygun filtirlemeq ve List qaytarmaq
 /// <summary>
 /// Report quantity at point in time.
 /// Classic usage is for reporting operation starts
 /// from this kind of report you can understand the throughput over the time-line.
 /// </summary>
 /// <param name="importance">The importance.</param>
 /// <param name="tags">The tags.</param>
 public void Count(
     ImportanceLevel importance,
     IReadOnlyDictionary <string, string> tags)
 {
     Count(importance, tags, 1);
 }
Exemple #24
0
        }   //DataBase-den Userleri Statusuna uygun filtirlemeq ve List qaytarmaq

        public List <TodoEntity> GetAll(ImportanceLevel importanceLevel)
        {
            return(_todoEntities.Where(i => i.ImportanceLevel == importanceLevel).ToList());
        }  //DataBase-den Userleri ImportanceLevel uygun filtirlemeq ve List qaytarmaq
Exemple #25
0
        public static string GetIcon(ImportanceLevel imp, string sizeInCss = "90%;", string glyphiconSymbol = "exclamation-sign")
        {
            string res = "<span class=\"text{0} glyphicon glyphicon-{3}\" style=\"font-size:{1}\" aria-hidden=\"true\" title=\"{2}\"></span>";

            return(string.Format(res, GetCssClass(imp, true), sizeInCss, imp.ToNiceDisplayName(), glyphiconSymbol));
        }
Exemple #26
0
		public abstract void Write (string msg, ImportanceLevel level);
Exemple #27
0
 public MinimalImportanceScope(ImportanceLevel importance)
 {
     _previousMinimalImportanceLevel = MinimalImportanceLevel;
     MinimalImportanceLevel          = importance;
 }
Exemple #28
0
		public override void Write (string tag, string msg, ImportanceLevel importance)
		{
			int v = Log.VerboseLevel;
			switch (v) {
			case 0 :
				break;
			case 1 :
				if (importance >= ImportanceLevel.HIGH) {
					DoWrite (tag, msg);
				}
				break;
			case 2 :
				if (importance >= ImportanceLevel.MEDIUM) {
					DoWrite (tag, msg);
				}
				break;
			case 3 :
				DoWrite (tag, msg);
				break;
			default:
				break;
			}
		}
Exemple #29
0
		public void Write (string tag, string msg, ImportanceLevel importance)
		{
			foreach (ILogger logger in consumers) {
				if (tag == null || tag == "") {
					logger.Write (msg, importance);
				} else {
					logger.Write (tag, msg, importance);
				}
			}
		}
Exemple #30
0
		public void Write (string msg, ImportanceLevel importance)
		{
			Write (null, msg, importance);
		}
Exemple #31
0
		public abstract void Write (string tag, string msg, ImportanceLevel importance);
 public AndroidChannel(string id, string name, ImportanceLevel importance)
 {
     this.Id         = id;
     this.Name       = name;
     this.Importance = importance;
 }
 public AndroidChannel(string id, string name, ImportanceLevel importance)
 {
     Id         = id;
     Name       = name;
     Importance = importance;
 }
Exemple #34
0
 public InfoFact(string txt, ImportanceLevel level)
 {
     this.Text  = txt;
     this.Level = level;
 }
Exemple #35
0
 public static void Log(object obj, ImportanceLevel importance = ImportanceLevel.Debug)
 {
     Log(obj.ToString());
 }