コード例 #1
0
ファイル: Program.cs プロジェクト: hiredgunhouse/evtailnet
        private static void Output(EventLogEntry entry, EvTailConfigurationModel configuration, StreamWriter outputFile)
        {
            var msg = string.Format("{0} {1} {2}", entry.TimeGenerated, entry.Source, entry.Message);

            if (configuration.outputToConsole)
            {
                Console.Write(msg);
            }

            outputFile?.Write(msg);
            outputFile?.Flush();

            if (!entry.Message.EndsWith(Environment.NewLine))
            {
                Console.Write(Environment.NewLine);
                outputFile?.Write(Environment.NewLine);
            }
        }
コード例 #2
0
        private static void Output(EventLogEntry entry, EvTailConfigurationModel configuration, StreamWriter outputFile)
        {
            var msg = string.Format("{0} {1} {2}", entry.TimeGenerated, entry.Source, entry.Message);

            if (configuration.outputToConsole)
            {
                Console.Write(msg);
            }

            outputFile?.Write(msg);
            outputFile?.Flush();

            if (!entry.Message.EndsWith(Environment.NewLine))
            {
                Console.Write(Environment.NewLine);
                outputFile?.Write(Environment.NewLine);
            }
        }
コード例 #3
0
        private static void TailEventLog(EvTailConfigurationModel configuration)
        {
            if (!string.IsNullOrEmpty(configuration.outputFile))
            {
                _outputFile = new StreamWriter(configuration.outputFile, true);
            }

            var el = new EventLog(configuration.logName, Environment.MachineName);

            el.EntryWritten += (sender, eargs) =>
            {
                var entry = eargs.Entry;

                SetConsoleColors(entry.Source, entry.Message, configuration.errorStrings);
                Output(entry, configuration, _outputFile);
                ReSetConsoleColors();
            };
            el.EnableRaisingEvents = true;
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: hiredgunhouse/evtailnet
        private static void TailEventLog(EvTailConfigurationModel configuration)
        {
            if (!string.IsNullOrEmpty(configuration.outputFile))
            {
                _outputFile = new StreamWriter(configuration.outputFile, true);
            }

            var el = new EventLog(configuration.logName, Environment.MachineName);
            el.EntryWritten += (sender, eargs) =>
            {
                var entry = eargs.Entry;

                SetConsoleColors(entry.Source, entry.Message, configuration.errorStrings);
                Output(entry, configuration, _outputFile);
                ReSetConsoleColors();
            };
            el.EnableRaisingEvents = true;
        }