コード例 #1
0
 public void OutputContent(string message, OutputLevel level = OutputLevel.Information)
 {
     if (_minimumLevel <= level)
     {
         Console.WriteLine(message);
     }
 }
コード例 #2
0
 public void WriteLine(string message, OutputLevel level)
 {
     Messages.Add(new OutputMessage()
     {
         Message = message, Level = level
     });
 }
コード例 #3
0
 public static void Write(string value, OutputLevel messageOutputLevel = OutputLevel.DEBUG)
 {
     if ((int)messageOutputLevel <= (int)ConsoleWriter.OutputLevel)
     {
         Console.Write(value);
     }
 }
コード例 #4
0
        /// <summary>
        /// Writes the messasges from the commands
        /// </summary>
        /// <param name="messages"></param>
        public static void Write(IList <string> lines, OutputLevel level = OutputLevel.Normal,
                                 int blanks = 0, int indent = 0, bool isNested = true)
        {
            StringBuilder builder = new StringBuilder();

            while (blanks > 0)
            {
                Console.WriteLine(string.Empty);
                blanks--;
            }

            foreach (var line in lines)
            {
                for (int i = 0; i < indent; i++)
                {
                    if (i == indent - 1 && isNested)
                    {
                        builder.Append("  - ");
                    }
                    else
                    {
                        builder.Append("    ");
                    }
                }

                builder.Append(line.ToString() + Environment.NewLine);
            }

            Console.ForegroundColor = GetColor(level);
            Console.Write(builder.ToString());
            Console.ForegroundColor = ConsoleColor.White;
        }
コード例 #5
0
ファイル: Log.cs プロジェクト: laurettevanzanten/ARgame
        private void TryWriteToTable(string channel, string source, OutputLevel level, string message)
        {
            try
            {
                if (!_log.TryGetValue(channel, out var queue))
                {
                    queue         = new ConcurrentDictionary <LogEntry, LogEntry>();
                    _log[channel] = queue;
                }

                var newItem = new LogEntry()
                {
                    Level     = level,
                    Source    = string.IsNullOrEmpty(source) ? UnknownSource : source,
                    Message   = message,
                    TimeStamp = DateTime.Now,
                };

                queue[newItem] = newItem;
            }
            catch (Exception e)
            {
                Debug.WriteLine("caught unexpected exception " + e);
            }
        }
コード例 #6
0
        public void ProcessOtherCasts(OutputLevel outputLevel)
        {
            const String source = "namespace SomeNamespace\r\n" +
                                  "{\r\n" +
                                  "    public class SomeBaseClass\r\n" +
                                  "    {\r\n" +
                                  "    }\r\n" +
                                  "    public class SomeDerivedClass : SomeBaseClass\r\n" +
                                  "    {\r\n" +
                                  "    }\r\n" +
                                  "    public class SomeClass\r\n" +
                                  "    {\r\n" +
                                  "        public void SomeMethod()\r\n" +
                                  "        {\r\n" +
                                  "            int i1 = 666;\r\n" +
                                  "            long i2 = (long) i1;\r\n" +
                                  "            short i3 = (short) i1;\r\n" +
                                  "            uint i4 = (uint) i1;\r\n" +
                                  "            object s1 = \"IDDQD\";\r\n" +
                                  "            string s2 = (string) s1;\r\n" +
                                  "            SomeDerivedClass someObj1 = new SomeDerivedClass();\r\n" +
                                  "            SomeBaseClass someObj2 = (SomeBaseClass) someObj1;\r\n" +
                                  "            SomeDerivedClass someObj3 = (SomeDerivedClass) someObj2;\r\n" +
                                  "        }\r\n" +
                                  "    }\r\n" +
                                  "}\r\n";
            const String filePath = "C:\\SomeFolder\\SomeClass.cs";

            AnalyzerHelper.Process(_analyzerFactory, source, "CastToSameType", filePath, outputLevel, true, "");
        }
コード例 #7
0
ファイル: Output.cs プロジェクト: DaimOwns/Snowlight
        private static void SetColorSchemeForSeverity(OutputLevel SeverityLevel)
        {
            switch (SeverityLevel)
            {
            case OutputLevel.CriticalError:

                ApplyColorScheme(ConsoleColor.Red);
                break;

            case OutputLevel.Warning:

                ApplyColorScheme(ConsoleColor.Yellow);
                break;

            case OutputLevel.Notification:

                ApplyColorScheme(ConsoleColor.Green);
                break;

            case OutputLevel.DebugInformation:

                ApplyColorScheme(ConsoleColor.DarkGray);
                break;

            case OutputLevel.Informational:
            default:

                ResetColorScheme();
                break;
            }
        }
コード例 #8
0
        //TODO: All outputs should go via this method! (Entry to this method is from different methods, should only be one, or)
        protected internal virtual Location WriteLineEx(string value, OutputLevel level)
        {
            if (ConsoleManager.ForegroundColor == ConsoleManager.BackgroundColor)
            {
                ConsoleManager.ForegroundColor = ConsoleManager.ForegroundColor != ConsoleColor.Black ? ConsoleColor.Black : ConsoleColor.White;
            }

            var lines             = value.Split('\n');
            var endOfTextLocation = new Location(CursorLeft, CursorTop);

            foreach (var line in lines)
            {
                var r = line.Length % BufferWidth;
                if (r == 0)
                {
                    if (string.IsNullOrEmpty(line))
                    {
                        ConsoleManager?.WriteLine(line);
                    }
                    else
                    {
                        ConsoleManager?.Write(line);
                        endOfTextLocation = new Location(CursorLeft, CursorTop);
                    }
                }
                else
                {
                    ConsoleManager?.WriteLine(line);
                }
            }
            OnLineWrittenEvent(new LineWrittenEventArgs(value, level));
            return(endOfTextLocation);
        }
コード例 #9
0
 private bool GetSetting(OutputType outputType, OutputLevel outputLevel, bool defaultValue)
 {
     var settingName = string.Format("{0}{1}", outputType, outputLevel);
     var data = System.Configuration.ConfigurationManager.AppSettings[settingName];
     bool result;
     return bool.TryParse(data, out result) ? result : defaultValue;
 }
コード例 #10
0
        private static void smethod_3(OutputLevel outputLevel_1)
        {
            switch (outputLevel_1)
            {
            case OutputLevel.DebugInformation:
                smethod_1(ConsoleColor.DarkGray);
                return;

            case OutputLevel.DebugNotification:
                smethod_1(ConsoleColor.DarkGreen);
                return;

            case OutputLevel.Notification:
                smethod_1(ConsoleColor.Green);
                return;

            case OutputLevel.Warning:
                smethod_1(ConsoleColor.Yellow);
                return;

            case OutputLevel.CriticalError:
                smethod_1(ConsoleColor.Red);
                return;
            }
            smethod_0();
        }
コード例 #11
0
 public static void InitializeStream(bool EnableLogging, OutputLevel VerbosityLevel)
 {
     bool_0        = EnableLogging;
     outputLevel_0 = VerbosityLevel;
     object_0      = new object();
     if (EnableLogging)
     {
         DateTime now  = DateTime.Now;
         string   path = Environment.CurrentDirectory + Constants.LogFileDirectory + @"\";
         string_0 = string.Concat(new object[] { path, now.Day, now.Month, now.Year, now.Hour, now.Minute, now.Second, ".log" });
         try
         {
             if (!Directory.Exists(path))
             {
                 Directory.CreateDirectory(path);
             }
             File.WriteAllText(string_0, smethod_4(), Constants.DefaultEncoding);
         }
         catch (Exception exception)
         {
             Console.WriteLine("Error thrown by StreamWriter. Stack trace:\r\n" + exception.ToString());
             bool_0 = false;
         }
     }
     ClearStream();
     WriteBanner();
 }
コード例 #12
0
 public override void WriteLine(OutputLevel Level, string Message)
 {
     foreach (OutputDevice Output in Outputs)
     {
         Output.WriteLine(Level, Message);
     }
 }
コード例 #13
0
        private bool GetSetting(OutputLevel outputLevel, bool defaultValue)
        {
            var  data = System.Configuration.ConfigurationManager.AppSettings[string.Format("Log{0}", outputLevel)];
            bool result;

            return(bool.TryParse(data, out result) ? result : defaultValue);
        }
コード例 #14
0
 public override void WriteLine(OutputLevel Level, string Message)
 {
     lock (this)
     {
         Inner.WriteLine(Level, Message);
     }
 }
コード例 #15
0
 public override void WriteLine(OutputLevel Level, string Message)
 {
     if (Level >= MinLevel)
     {
         Console.WriteLine(Message);
     }
 }
コード例 #16
0
        private static ConsoleColor GetColor(OutputLevel level)
        {
            switch (level)
            {
            case OutputLevel.Important:     //Magenta
                return(ConsoleColor.Magenta);

            case OutputLevel.Normal:     //White
                return(ConsoleColor.White);

            case OutputLevel.Success:     //Green
                return(ConsoleColor.DarkGreen);

            case OutputLevel.Warning:     //Yellow
                return(ConsoleColor.DarkYellow);

            case OutputLevel.Error:     // Red
                return(ConsoleColor.DarkRed);

            case OutputLevel.Link:      // Dark Cyan
                return(ConsoleColor.DarkCyan);

            case OutputLevel.Info:      //Grey
                return(ConsoleColor.DarkGray);

            default:
                return(ConsoleColor.White);
            }
        }
コード例 #17
0
 CommandOutput(OutputLevel level, PropertyDecorator <string> message, DateTime creationTime)
     : this()
 {
     Level        = level;
     Message      = message;
     CreationTime = creationTime;
 }
コード例 #18
0
 /// <summary>
 /// Write string with a given console color
 /// </summary>
 /// <param name="output">Output instance the method is being invoked with.</param>
 /// <param name="message">Message to be written</param>
 /// <param name="level">OutputLevel</param>
 /// <param name="foregroundColor">Console color for the output message</param>
 public static void Write(this IOutput output, string message, OutputLevel level, ConsoleColor foregroundColor)
 {
     SetColorForAction(foregroundColor, () =>
     {
         output.Write(message, level);
     });
 }
コード例 #19
0
 /// <summary>
 /// Internal main write method.
 /// Depending on the output type, we may want to 
 /// </summary>
 /// <param name="textWriter"></param>
 /// <param name="outputLevel"></param>
 /// <param name="format"></param>
 /// <param name="arg"></param>
 public static void WriteLine(TextWriter textWriter, OutputLevel outputLevel, string format, params object[] arg)
 {
     if (IsConsole(textWriter))
         WriteConsoleLine(outputLevel, format, arg);
     else
         textWriter.WriteLine(format, arg);
 }
コード例 #20
0
ファイル: Output.cs プロジェクト: fuding/Snowlight
        public static void InitializeStream(bool EnableLogging, OutputLevel VerbosityLevel)
        {
            mEnableLogging = EnableLogging;
            mVerbosityLevel = VerbosityLevel;
            mWritebackSyncRoot = new object();

            if (EnableLogging)
            {
                DateTime Now = DateTime.Now;
                string LogDirectory = Constants.LogFileDirectory;
                mLogFilePath = LogDirectory + Now.Day + Now.Month + Now.Year + Now.Hour + Now.Minute + Now.Second + ".log";

                try
                {
                    if (!Directory.Exists(LogDirectory))
                    {
                        Directory.CreateDirectory(LogDirectory);
                    }

                    File.WriteAllText(mLogFilePath, ComposeDefaultLogHeader(), Constants.DefaultEncoding);
                }
                catch (Exception)
                {
                    mEnableLogging = false;
                    WriteLine("LOGGING DISABLED" + mLogFilePath);
                    Console.ReadKey();
                }
            }

            ClearStream();
            WriteBanner();
        }
コード例 #21
0
        private async Task ExecuteProjectsAnalysisImplAsync(IList <ProjectData> projects, ProjectsAnalysisStat statistics, String appPath, IConfigDataProvider configDataProvider)
        {
            await OutputHelper.OutputMessageAsync(ServiceProvider, $"Source code analysis for {statistics.TargetType} named \"{statistics.ProjectNames}\" is started");

            foreach (ProjectData project in projects)
            {
                String target = project.FileName;
                if (String.Equals(project.LanguageId, LanguageCSharpId))
                {
                    String          configPath  = ConfigFinder.FindConfig(configDataProvider, target);
                    OutputLevel     outputLevel = configDataProvider.GetOutputLevel();
                    ExecutionResult result      = await ExecutionHelper.ExecuteSourceCodeAnalysisAsync(appPath, target, configPath, outputLevel);

                    if (result.ExitCode == 0)
                    {
                        ++statistics.SuccessCount;
                    }
                    else
                    {
                        ++statistics.FailedCount;
                    }
                    await OutputHelper.OutputTargetAnalysisResultAsync(ServiceProvider, result, target, "project");
                }
                else
                {
                    ++statistics.SkippedCount;
                    await OutputHelper.OutputMessageAsync(ServiceProvider, $"Project \"{target}\" can't be processed due to unsupported language");
                }
            }
            await OutputHelper.OutputMessageAsync(ServiceProvider, $"Source code analysis for {statistics.TargetType} named \"{statistics.ProjectNames}\" is finished");

            await UIHelper.ShowProjectsSummaryAsync(_package, statistics);
        }
コード例 #22
0
        public void ProcessWithoutExactMatch(OutputLevel outputLevel)
        {
            const String source = "namespace SomeNamespace\r\n" +
                                  "{\r\n" +
                                  "    public class OtherClass\r\n" +
                                  "    {\r\n" +
                                  "    }\r\n" +
                                  "    public class SoMeClass\r\n" +
                                  "    {\r\n" +
                                  "    }\r\n" +
                                  "    public class SOmeClass\r\n" +
                                  "    {\r\n" +
                                  "    }\r\n" +
                                  "    public class Someclass\r\n" +
                                  "    {\r\n" +
                                  "    }\r\n" +
                                  "    public class AnotherClass\r\n" +
                                  "    {\r\n" +
                                  "    }\r\n" +
                                  "}";
            const String filePath = "C:\\SomeFolder\\SomeClass.cs";
            const String expectedOutputTemplate = "{0}(6): [ERROR]: Found type named \"SomeNamespace.SoMeClass\" which corresponds the filename \"SomeClass.cs\" only at ignoring case\r\n" +
                                                  "{0}(9): [ERROR]: Found type named \"SomeNamespace.SOmeClass\" which corresponds the filename \"SomeClass.cs\" only at ignoring case\r\n" +
                                                  "{0}(12): [ERROR]: Found type named \"SomeNamespace.Someclass\" which corresponds the filename \"SomeClass.cs\" only at ignoring case\r\n";
            String expectedOutput = String.Format(expectedOutputTemplate, filePath);

            AnalyzerHelper.Process(_analyzerFactory, source, "BadFilenameCase", filePath, outputLevel, false, expectedOutput);
        }
コード例 #23
0
        private void Send(string line, OutputLevel level, bool isNested)
        {
            if (IsQuiet)
            {
                return;
            }

            List <string> lines = new List <string>();

            lines.Add(line);

            OutputEventHandler handler = OnOutput;

            if (handler != null)
            {
                OutputEventArgs e = new OutputEventArgs()
                {
                    Lines    = lines,
                    Level    = level,
                    Indent   = CurrentIndent,
                    IsNested = isNested
                };

                handler(this, e);
            }
        }
コード例 #24
0
        static void Main(string[] args)
        {
            string progPath;

            if (args.Length > 0)
            {
                progPath = args[0];
            }
            else
            {
                Console.WriteLine("Source path:");
                Console.Write(">");
                progPath = Console.ReadLine();
            }
            OutputLevel outLevel = args.Length > 1 ? (OutputLevel)Convert.ToInt32(args[1]) : OutputLevel.ERROR;

            ConsoleWriter.OutputLevel = outLevel;
            try
            {
                Interpreter interp = new Interpreter(progPath);
                interp.Run();
            }
            catch (Exception ex)
            {
                bool includeStack = ex.GetType() == typeof(SpiceException);
                ConsoleWriter.Write(ex, includeStack);
            }
        }
コード例 #25
0
ファイル: Output.cs プロジェクト: DaimOwns/Snowlight
        public static void InitializeStream(bool EnableLogging, OutputLevel VerbosityLevel)
        {
            mEnableLogging     = EnableLogging;
            mVerbosityLevel    = VerbosityLevel;
            mWritebackSyncRoot = new object();

            if (EnableLogging)
            {
                DateTime Now          = DateTime.Now;
                string   LogDirectory = Constants.LogFileDirectory;
                mLogFilePath = LogDirectory + Now.Day + Now.Month + Now.Year + Now.Hour + Now.Minute + Now.Second + ".log";

                try
                {
                    if (!Directory.Exists(LogDirectory))
                    {
                        Directory.CreateDirectory(LogDirectory);
                    }

                    File.WriteAllText(mLogFilePath, ComposeDefaultLogHeader(), Constants.DefaultEncoding);
                }
                catch (Exception)
                {
                    mEnableLogging = false;
                    WriteLine("LOGGING DISABLED" + mLogFilePath);
                    Console.ReadKey();
                }
            }

            ClearStream();
            WriteBanner();
        }
コード例 #26
0
        private void WriteLine(string value, OutputLevel level = OutputLevel.Default, ConsoleColor?textColor = null, ConsoleColor?textBackgroundColor = null)
        {
            if (value == null)
            {
                ConsoleManager?.WriteLine(null);
                return;
            }

            var linesToInsert       = GetLineCount(value);
            var inputBufferLines    = InputInstance.CurrentBufferLineCount;
            var intCursorLineOffset = MoveCursorUp();
            var cursorLocation      = MoveInputBufferDown(linesToInsert, inputBufferLines); //TODO: If this is located at the end of the buffer, then the buffer should be pushed...

            //NOTE: At this point, the buffer is moved down. The cursor is ready to output the 'value' to be written.
            //When done the buffer (ie '> ') should still be visible, and the cursor should be moved in position

            ColorManager(level, textColor, textBackgroundColor, () =>
            {
                var corr = 0;
                var t1   = CursorTop; //NOTE: The actual cursor location after insert... should normally be one line above the input buffer location, but if the output is exactly the sise of the width, then the buffer would have beend moved down one line too low. In this case the buffer should not moved vertically. This is calculated by the corr value.
                try
                {
                    WriteLineEx(value, level);
                    corr = CursorTop - t1 - linesToInsert;
                }
                finally
                {
                    RestoreCursor(cursorLocation.Left, intCursorLineOffset - corr);
                    OnLinesInsertedEvent(linesToInsert);
                }
            });
        }
コード例 #27
0
        public void ProcessNonAsciiIdentifiers(OutputLevel outputLevel)
        {
            const String source = "namespace SomeНеймспейс\r\n" +
                                  "{\r\n" +
                                  "    public class ДругойClass\r\n" +
                                  "    {\r\n" +
                                  "    }\r\n" +
                                  "    public class SomeКласс\r\n" +
                                  "    {\r\n" +
                                  "        public void SomeМетод()\r\n" +
                                  "        {\r\n" +
                                  "            int intПеременная = 666;\r\n" +
                                  "            string строковаяVar1 = \"IDDQD\";\r\n" +
                                  "            string stringVar2 = \"ИДДКуД\";\r\n" +
                                  "            ДругойClass другойObj = new ДругойClass();" +
                                  "        }\r\n" +
                                  "    }\r\n" +
                                  "}";
            const String filePath = "C:\\SomeFolder\\SomeClass.cs";
            const String expectedOutputTemplate = "{0}(1): [ERROR]: Found non-ASCII identifier \"SomeНеймспейс\"\r\n" +
                                                  "{0}(3): [ERROR]: Found non-ASCII identifier \"ДругойClass\"\r\n" +
                                                  "{0}(6): [ERROR]: Found non-ASCII identifier \"SomeКласс\"\r\n" +
                                                  "{0}(8): [ERROR]: Found non-ASCII identifier \"SomeМетод\"\r\n" +
                                                  "{0}(10): [ERROR]: Found non-ASCII identifier \"intПеременная\"\r\n" +
                                                  "{0}(11): [ERROR]: Found non-ASCII identifier \"строковаяVar1\"\r\n" +
                                                  "{0}(13): [ERROR]: Found non-ASCII identifier \"ДругойClass\"\r\n" +
                                                  "{0}(13): [ERROR]: Found non-ASCII identifier \"другойObj\"\r\n" +
                                                  "{0}(13): [ERROR]: Found non-ASCII identifier \"ДругойClass\"\r\n";
            String expectedOutput = String.Format(expectedOutputTemplate, filePath);

            AnalyzerHelper.Process(_analyzerFactory, source, "NonAsciiIdentifiers", filePath, outputLevel, false, expectedOutput);
        }
コード例 #28
0
        protected internal Tuple <ConsoleColor?, ConsoleColor?> GetConsoleColor(OutputLevel outputLevel)
        {
            switch (outputLevel)
            {
            case OutputLevel.Default:
                return(new Tuple <ConsoleColor?, ConsoleColor?>(null, null));

            case OutputLevel.Information:
                return(GetConsoleColor("Information", ConsoleColor.Green, null));

            case OutputLevel.Warning:
                return(GetConsoleColor("Warning", ConsoleColor.Yellow, null));

            case OutputLevel.Error:
                return(GetConsoleColor("Error", ConsoleColor.Red, null));

            case OutputLevel.Event:
                return(GetConsoleColor("Event", ConsoleColor.Cyan, null));

            case OutputLevel.Help:
                return(GetConsoleColor("Help", ConsoleColor.Magenta, null));

            case OutputLevel.Title:
                return(GetConsoleColor("Title", ConsoleColor.DarkCyan, null));

            default:
                return(new Tuple <ConsoleColor?, ConsoleColor?>(null, null));
            }
        }
コード例 #29
0
 public void Output(OutputLevel level, string message)
 {
     foreach (IOutput terminal in this._outputTerminals)
     {
         terminal.Output(level, message);
     }
 }
コード例 #30
0
 public void WriteLine(OutputLevel level, string value)
 {
     foreach (var o in this.outputs)
     {
         o.WriteLine(level, value);
     }
 }
コード例 #31
0
        public static void Write(string line, OutputLevel level = OutputLevel.Normal,
                                 int blanks = 0, int indent = 0)
        {
            List <string> lines = new List <string>();

            lines.Add(line);
            Write(lines, level, blanks, indent);
        }
コード例 #32
0
        public CountLinesProgram()
        {
            this.extensions = new List <string>(Input("请输入合法拓展名(要加.),使用;号隔开:").Trim().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
            int priority = int.Parse(Input("输出等级(无显示=0, 极少=1, 简略=2, 详细=3, 完全=4):"));

            this.priority       = (OutputLevel)priority;
            everyExtensionLines = new int[this.extensions.Count];
        }
コード例 #33
0
        /// <summary>
        /// Formats the message.
        /// </summary>
        /// <param name="output">An output instance to write the message.</param>
        /// <param name="level">Message level.</param>
        /// <param name="messageTypeFormat">Format string for the message type.</param>
        /// <param name="format">Format string for the error message.</param>
        /// <param name="args">Arguments to format into the format string.</param>
        private static void Output(IOutput output, OutputLevel level, string messageTypeFormat, string format, params object[] args)
        {
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            output.WriteLine(Format(messageTypeFormat, format, args), level);
        }
コード例 #34
0
ファイル: Output.cs プロジェクト: cpatmoore/bio
        /// <summary>
        /// Writes the message out to the console based on the current output level
        /// </summary>
        public static void WriteLine(OutputLevel level, string message = "", params object[] args)
        {
            if ((level & TraceLevel) == 0)
                return;

            if (level == OutputLevel.Error)
                Console.Error.WriteLine(message, args);
            else
                Console.WriteLine(message, args);
        }
コード例 #35
0
        protected override void WriteLineEx(string value, OutputLevel level)
        {
            var output = string.Format("{0} {1}: {2}", DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString(), value);
            if (!EventLog.SourceExists(_eventLogSource))
            {
                try
                {
                    EventLog.CreateEventSource(_eventLogSource, "Application");
                }
                catch (Exception)
                {
                    WriteLine(string.Format("Unable to create event source named {0} in the event log.", _eventLogSource), OutputLevel.Error, null);
                }
            }

            switch (level)
            {
                case OutputLevel.Default:
                    output = value;
                    if (GetSetting(OutputType.Log, level, false))
                        EventLog.WriteEntry(_eventLogSource, value, EventLogEntryType.Information);
                    if (GetSetting(OutputType.Trace, level, false))
                        Trace.TraceInformation(value);
                    break;
                case OutputLevel.Information:
                    if (GetSetting(OutputType.Log, level, true))
                        EventLog.WriteEntry(_eventLogSource, value, EventLogEntryType.Information);
                    if (GetSetting(OutputType.Trace, level, true))
                        Trace.TraceInformation(value);
                    break;
                case OutputLevel.Warning:
                    if (GetSetting(OutputType.Log, level, true))
                        EventLog.WriteEntry(_eventLogSource, value, EventLogEntryType.Warning);
                    if (GetSetting(OutputType.Trace, level, true))
                        Trace.TraceWarning(value);
                    break;
                case OutputLevel.Error:
                    if (GetSetting(OutputType.Log, level, true))
                        EventLog.WriteEntry(_eventLogSource, value, EventLogEntryType.Error);
                    if (GetSetting(OutputType.Trace, level, true))
                        Trace.TraceError(value);
                    break;
                default:
                    throw new ArgumentOutOfRangeException(string.Format("Unknown level {0}.", level));
            }

            base.WriteLineEx(output, level);
        }
コード例 #36
0
        protected override void WriteLineEx(string value, OutputLevel outputLevel)
        {
            base.WriteLineEx(value, outputLevel);

            //var builder = new PromptBuilder();
            //builder.StartSentence();
            //builder.AppendText(value);
            //builder.EndSentence();

            //using (var synthesizer = new SpeechSynthesizer())
            //{
            //    //synthesizer.SelectVoice("Microsoft David Desktop");
            //    //synthesizer.SelectVoice("Microsoft Hazel Desktop");
            //    synthesizer.SelectVoice("Microsoft Zira Desktop");
            //    synthesizer.Speak(builder);
            //}
        }
コード例 #37
0
 /// <summary>
 /// Writes to console, using specified information level
 /// </summary>
 /// <param name="outputLevel"></param>
 /// <param name="format"></param>
 /// <param name="arg"></param>
 public static void WriteConsoleLine(OutputLevel outputLevel, string format, params object[] arg)
 {
     ConsoleColor? consoleForegroundColor;
     TextWriter consoleOutput;
     // depending on output level, color and textwriter are set
     switch (outputLevel)
     {
     case OutputLevel.Debug:
         consoleForegroundColor = ConsoleColor.Blue;
         consoleOutput = Console.Out;
         break;
     case OutputLevel.Information:
         consoleForegroundColor = null;
         consoleOutput = Console.Out;
         break;
     case OutputLevel.Warning:
         consoleForegroundColor = ConsoleColor.Yellow;
         consoleOutput = Console.Out;
         break;
     case OutputLevel.Error:
         consoleForegroundColor = ConsoleColor.Red;
         consoleOutput = Console.Error;
         break;
     default:
         throw new ArgumentOutOfRangeException("outputLevel");
     }
     try
     {
         // optionnaly set the color
         if (consoleForegroundColor.HasValue)
             Console.ForegroundColor = consoleForegroundColor.Value;
         // and write
         consoleOutput.WriteLine(format, arg);
     }
     finally
     {
         // since the WriteLine may return exceptions if the format is invalid
         // we reset the color here
         if (consoleForegroundColor.HasValue)
             Console.ResetColor();
     }
 }
コード例 #38
0
        public void WriteLine(string value, OutputLevel level, ConsoleColor? consoleColor = null)
        {
            lock (_syncRoot)
            {
                var linesToInsert = GetLineCount(value);
                var inputBufferLines = InputManager.CurrentBufferLineCount;
                var intCursorLineOffset = MoveCursorUp();
                var cursorLeft = MoveInputBufferDown(linesToInsert, inputBufferLines);

                var defaultColor = ConsoleColor.White;
                if (consoleColor == null)
                {
                    consoleColor = CommandBase.GetConsoleColor(level);
                }

                if (consoleColor != null)
                {
                    defaultColor = ForegroundColor;
                    ForegroundColor = consoleColor.Value;
                }

                try
                {
                    WriteLineEx(value, level);
                }
                finally
                {
                    if (consoleColor != null)
                    {
                        ForegroundColor = defaultColor;
                    }

                    RestoreCursor(cursorLeft);
                    InvokeLinesInsertedEvent(linesToInsert);
                    MoveCursorDown(intCursorLineOffset);
                }
            }
        }
コード例 #39
0
 public SendBusinessEventArgs(IDatabaseConfig databaseConfig, Exception exception)
 {
     _databaseConfig = databaseConfig;
     _exception = exception;
     _outputLevel = OutputLevel.Error;
 }
コード例 #40
0
 public SendBusinessEventArgs(string message, int count, OutputLevel outputLevel)
 {
     _message = message;
     _outputLevel = outputLevel;
 }
コード例 #41
0
ファイル: Output.cs プロジェクト: fuding/Snowlight
 public static void SetVerbosityLevel(OutputLevel OutputLevel)
 {
     mVerbosityLevel = OutputLevel;
 }
コード例 #42
0
 public SendCompleteEventArgs(ISenderConfiguration senderConfiguration, string message, int count, OutputLevel outputLevel)
 {
     _senderConfiguration = senderConfiguration;
     _message = message;
     Level = outputLevel;
 }
コード例 #43
0
ファイル: Output.cs プロジェクト: fuding/Snowlight
        private static void SetColorSchemeForSeverity(OutputLevel SeverityLevel)
        {
            switch (SeverityLevel)
            {
                case OutputLevel.CriticalError:

                    ApplyColorScheme(ConsoleColor.Red);
                    break;

                case OutputLevel.Warning:

                    ApplyColorScheme(ConsoleColor.Yellow);
                    break;

                case OutputLevel.Notification:

                    ApplyColorScheme(ConsoleColor.Green);
                    break;

                case OutputLevel.DebugInformation:

                    ApplyColorScheme(ConsoleColor.DarkGray);
                    break;

                case OutputLevel.Informational:
                default:

                    ResetColorScheme();
                    break;
            }
        }
コード例 #44
0
 public SendBusinessEventArgs(IDatabaseConfig databaseConfig, string message, int count, OutputLevel outputLevel)
 {
     _databaseConfig = databaseConfig;
     _message = message;
     _outputLevel = outputLevel;
 }
コード例 #45
0
 public CollectRegisterCounterValuesEventArgs(string engineName, Exception exception)
 {
     _engineName = engineName;
     _message = exception.Message;
     _outputLevel = OutputLevel.Error;
 }
コード例 #46
0
ファイル: Output.cs プロジェクト: fuding/Snowlight
        public static void WriteLine(string Line, OutputLevel Level)
        {
            if (mVerbosityLevel <= Level)
            {
                Console.Write(FormatTimestamp());
                SetColorSchemeForSeverity(Level);

                Console.WriteLine(Line);
                ResetColorScheme();

                WriteLogIfNeeded(Line);
            }
        }
コード例 #47
0
 private void ShowOutput(string message, OutputLevel outputLevel)
 {
     OutputLine(message, outputLevel);
 }
コード例 #48
0
 public CollectRegisterCounterValuesEventArgs(string engineName, string message, OutputLevel outputLevel)
 {
     _engineName = engineName;
     _message = message;
     _outputLevel = outputLevel;
 }
コード例 #49
0
 public SendBusinessEventArgs(Exception exception)
 {
     _exception = exception;
     _outputLevel = OutputLevel.Error;
 }
コード例 #50
0
 public EngineActionEventArgs(string engineName, string message, OutputLevel outputLevel)
 {
     _engineName = engineName;
     _message = message;
     _outputLevel = outputLevel;
 }
コード例 #51
0
ファイル: Simulation.cs プロジェクト: smiley22/Network.Sim
        /// <summary>
        /// Writes the specified string followed by a newline to the output using the specified
        /// output-level and optionally the specified color.
        /// </summary>
        /// <param name="level">The output-level to output the string with.</param>
        /// <param name="s">The string to output to the console.</param>
        /// <param name="c">The color to use.</param>
		public static void WriteLine(OutputLevel level, string s, ConsoleColor c = ConsoleColor.DarkRed) {
			Write(level, s + Environment.NewLine, c);
		}
コード例 #52
0
ファイル: Output.cs プロジェクト: cpatmoore/bio
 /// <summary>
 /// Constructor
 /// </summary>
 static Output()
 {
     TraceLevel = 0;
 }
コード例 #53
0
ファイル: Simulation.cs プロジェクト: smiley22/Network.Sim
        /// <summary>
        /// Writes the specified string to the output using the specified output-level and optionally
        /// the specified color.
        /// </summary>
        /// <param name="level">The output-level to output the string with.</param>
        /// <param name="s">The string to output to the console.</param>
        /// <param name="c">The color to use.</param>
		public static void Write(OutputLevel level, string s, ConsoleColor c) {
			if (OutputLevel > 0 && !OutputLevel.HasFlag(level))
				return;
			var color = Console.ForegroundColor;
			Console.ForegroundColor = c;
			Console.Write(Time.ToString("D8") + " ns| " + s);
			Console.ForegroundColor = color;
		}
コード例 #54
0
 protected virtual void WriteLineEx(string value, OutputLevel level)
 {
     _consoleWriter.WriteLine(value);
 }
コード例 #55
0
 public CollectRegisterCounterValuesEventArgs(string engineName, int counters, Dictionary<string, long> timeInfo, double elapseOffset, OutputLevel outputLevel)
 {
     _engineName = engineName;
     _message = string.Format("Read {0} metrics in {1}ms. ElapseOffset: {2}ms", counters, new TimeSpan(timeInfo["Read"]).TotalMilliseconds.ToString("0.####"), elapseOffset.ToString("0.####"));
     _outputLevel = outputLevel;
 }