Пример #1
0
        private static void AttachLogParserToProcessError(Action <MySqlLogline> logRecived, Process process)
        {
            var outputBuffer = new StringBuilder();

            process.ErrorDataReceived += (sender, args) =>
            {
                outputBuffer.Append(" " + args.Data);
                var linesParsed = MySqlLogline.ParseLogLine(outputBuffer.ToString());
                if (linesParsed.Loglines.Any())
                {
                    var preOutput = outputBuffer.ToString().Substring(0,
                                                                      linesParsed.FirstCharConsumed);
                    if (!string.IsNullOrWhiteSpace(preOutput))
                    {
                        logRecived(new MySqlLogline()
                        {
                            Orginal  = preOutput,
                            LogLevel = "ERROR"
                        });
                    }
                    outputBuffer = outputBuffer.Remove(0, linesParsed.LastCharConsumed);
                    foreach (var linesParsedLogline in linesParsed.Loglines)
                    {
                        logRecived(linesParsedLogline);
                    }
                }
            };
        }
Пример #2
0
        private static void AttachLogParserToProcess(Action <MySqlLogline> logRecived, Process process)
        {
            var outputBuffer = new StringBuilder();

            process.OutputDataReceived += (sender, args) =>
            {
                outputBuffer.Append(args.Data);
                var linesParsed = MySqlLogline.ParseLogLine(outputBuffer.ToString());
                if (linesParsed.Loglines.Any())
                {
                    outputBuffer = outputBuffer.Remove(0, linesParsed.LastCharConsumed);
                    foreach (var linesParsedLogline in linesParsed.Loglines)
                    {
                        logRecived(linesParsedLogline);
                    }
                }
            };
        }