/// <summary>
 /// Initializes the logger, with alternate output handlers.
 /// </summary>
 /// <param name="verbosity"></param>
 /// <param name="write"></param>
 /// <param name="colorSet"></param>
 /// <param name="colorReset"></param>
 public SerialConsoleLogger
 (
     LoggerVerbosity verbosity,
     WriteHandler write,
     ColorSetter colorSet,
     ColorResetter colorReset
 )
 {
     InitializeConsoleMethods(verbosity, write, colorSet, colorReset);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes the logger, with alternate output handlers.
 /// </summary>
 /// <param name="verbosity"></param>
 /// <param name="write"></param>
 /// <param name="colorSet"></param>
 /// <param name="colorReset"></param>
 public SerialConsoleLogger
 (
     LoggerVerbosity verbosity,
     WriteHandler write,
     ColorSetter colorSet,
     ColorResetter colorReset
 )
 {
     InitializeConsoleMethods(verbosity, write, colorSet, colorReset);
 }
            internal virtual void PrintCounterMessage(WriteLinePrettyFromResourceDelegate writeLinePrettyFromResource, ColorSetter setColor, ColorResetter resetColor)
            {
                string time;

                if (!reenteredScope)
                {
                    // round: sub-millisecond values are not meaningful
                    time = String.Format(CultureInfo.CurrentCulture,
                                         "{0,5}", Math.Round(elapsedTime.TotalMilliseconds, 0));
                }
                else
                {
                    // no value available; instead display an asterisk
                    time = "    *";
                }

                writeLinePrettyFromResource(
                    2,
                    "PerformanceLine",
                    time,
                    String.Format(CultureInfo.CurrentCulture, "{0,-40}" /* pad to 40 align left */, scopeName),
                    String.Format(CultureInfo.CurrentCulture, "{0,3}", calls));
            }
        internal void InitializeConsoleMethods(LoggerVerbosity logverbosity, WriteHandler logwriter, ColorSetter colorSet, ColorResetter colorReset)
        {
            Verbosity    = logverbosity;
            WriteHandler = logwriter;
            IsRunningWithCharacterFileType();
            // This is a workaround, because the Console class provides no way to check that a color
            // can actually be set or not. Color cannot be set if the console has been redirected
            // in certain ways (e.g. how BUILD.EXE does it)
            bool canSetColor = true;

            try
            {
                ConsoleColor c = BackgroundColor;
            }
            catch (IOException)
            {
                // If the attempt to set a color fails with an IO exception then it is
                // likely that the console has been redirected in a way that cannot
                // cope with color (e.g. BUILD.EXE) so don't try to do color again.
                canSetColor = false;
            }

            if (colorSet != null && canSetColor)
            {
                this.setColor = colorSet;
            }
            else
            {
                this.setColor = DontSetColor;
            }

            if (colorReset != null && canSetColor)
            {
                this.resetColor = colorReset;
            }
            else
            {
                this.resetColor = DontResetColor;
            }
        }
Ejemplo n.º 5
0
            internal virtual void PrintCounterMessage(WriteLinePrettyFromResourceDelegate WriteLinePrettyFromResource, ColorSetter setColor, ColorResetter resetColor)
            {
                string time;
                if (!reenteredScope)
                {
                    // round: submillisecond values are not meaningful
                    time = String.Format(CultureInfo.CurrentCulture,
                        "{0,5}", Math.Round(elapsedTime.TotalMilliseconds, 0));
                }
                else
                {
                    // no value available; instead display an asterisk
                    time = "    *";
                }

                WriteLinePrettyFromResource
                    (
                        2,
                        "PerformanceLine",
                        time,
                        String.Format(CultureInfo.CurrentCulture,
                                "{0,-40}" /* pad to 40 align left */, scopeName),
                        String.Format(CultureInfo.CurrentCulture,
                                "{0,3}", calls)
                    );
            }
Ejemplo n.º 6
0
        internal void InitializeConsoleMethods(LoggerVerbosity logverbosity, WriteHandler logwriter, ColorSetter colorSet, ColorResetter colorReset)
        {
            this.verbosity = logverbosity;
            this.write = logwriter;
            IsRunningWithCharacterFileType();
            // This is a workaround, because the Console class provides no way to check that a color
            // can actually be set or not. Color cannot be set if the console has been redirected
            // in certain ways (e.g. how BUILD.EXE does it)
            bool canSetColor = true;

            try
            {
                ConsoleColor c = Console.BackgroundColor;
            }
            catch (IOException)
            {
                // If the attempt to set a color fails with an IO exception then it is
                // likely that the console has been redirected in a way that cannot
                // cope with color (e.g. BUILD.EXE) so don't try to do color again.
                canSetColor = false;
            }

            if ((colorSet != null) && canSetColor)
            {
                this.setColor = colorSet;
            }
            else
            {
                this.setColor = new ColorSetter(DontSetColor);
            }

            if ((colorReset != null) && canSetColor)
            {
                this.resetColor = colorReset;
            }
            else
            {
                this.resetColor = new ColorResetter(DontResetColor);
            }
        }