Ejemplo n.º 1
0
        public void Write(ScriptObservation observation)
        {
            Guard.NotNull(observation, nameof(observation));

            if (observation.Severity < _minimumSeverity)
            {
                return;
            }

            var severitySettings = ((int)observation.Severity < _severitySettings.Length)
                ? _severitySettings[(int)observation.Severity]
                : default(SeveritySettings);

            if (severitySettings.Color.HasValue)
            {
                var originalColor = Console.ForegroundColor;
                Console.ForegroundColor = severitySettings.Color.Value;
                WriteMessage(severitySettings.Prefix, observation);
                Console.ForegroundColor = originalColor;
            }
            else
            {
                WriteMessage(severitySettings.Prefix, observation);
            }
        }
Ejemplo n.º 2
0
 private void WriteMessage(string prefix, ScriptObservation observation)
 {
     Console.Write(prefix);
     Console.WriteLine(observation.Message);
     if (observation.Source != null)
     {
         Console.Write("Source: ");
         Console.WriteLine(observation.Source);
     }
 }
        public static void WriteFormat(this IScriptConsole obj, ScriptSeverity severity, Exception exception, string source, string format, params object[] args)
        {
            Guard.NotNullOrEmpty(format, nameof(format));

            obj.Write(ScriptObservation.CreateFormat(severity, format, args, source));
        }
        public static void Trace(this IScriptConsole obj, FormattableString message)
        {
            Guard.NotNull(obj, nameof(obj));

            obj.Write(ScriptObservation.Trace(message));
        }
        public static void ErrorFormat(this IScriptConsole obj, Exception exception, string source, string format, params object[] args)
        {
            Guard.NotNullOrEmpty(format, nameof(format));

            obj.Write(ScriptObservation.ErrorFormat(exception, source, format, args));
        }
        public static void Write(this IScriptConsole obj, ScriptSeverity severity, object message)
        {
            Guard.NotNull(obj, nameof(obj));

            obj.Write(ScriptObservation.Create(severity, message));
        }
        public static void Write(this IScriptConsole obj, ScriptSeverity severity, Exception exception, string source, FormattableString message)
        {
            Guard.NotNull(obj, nameof(obj));

            obj.Write(ScriptObservation.Create(severity, exception, source, message));
        }
        public static void Error(this IScriptConsole obj, Exception exception, string source, FormattableString message)
        {
            Guard.NotNull(obj, nameof(obj));

            obj.Write(ScriptObservation.Error(exception, source, message));
        }
        public static void Error(this IScriptConsole obj, Exception exception, object message)
        {
            Guard.NotNull(obj, nameof(obj));

            obj.Write(ScriptObservation.Error(exception, message));
        }
        public static void Error(this IScriptConsole obj, string source, object message)
        {
            Guard.NotNull(obj, nameof(obj));

            obj.Write(ScriptObservation.Error(source, message));
        }
        public static void WarningFormat(this IScriptConsole obj, string source, string format, params object[] args)
        {
            Guard.NotNullOrEmpty(format, nameof(format));

            obj.Write(ScriptObservation.WarningFormat(source, format, args));
        }
        public static void Warning(this IScriptConsole obj, Exception exception, string source, object message)
        {
            Guard.NotNull(obj, nameof(obj));

            obj.Write(ScriptObservation.Warning(exception, source, message));
        }
        public static void Warning(this IScriptConsole obj, string source, FormattableString message)
        {
            Guard.NotNull(obj, nameof(obj));

            obj.Write(ScriptObservation.Warning(source, message));
        }
        public static void Warning(this IScriptConsole obj, object message)
        {
            Guard.NotNull(obj, nameof(obj));

            obj.Write(ScriptObservation.Warning(message));
        }
        public static void Info(this IScriptConsole obj, Exception exception, FormattableString message)
        {
            Guard.NotNull(obj, nameof(obj));

            obj.Write(ScriptObservation.Info(exception, message));
        }