Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cat"></param>
        /// <param name="procId"></param>
        /// <param name="threadId"></param>
        /// <param name="tokens"></param>
        /// <returns></returns>
        internal string[] FormatPrologEx(
            OutputCategory cat, int procId, int threadId, string[] tokens)
        {
            // Date & Time
            DateTime dt = DateTime.Now;

            if (this.dateOn)
            {
                string d =
                    dt.ToString("yy-MM-dd ", DateTimeFormatInfo.InvariantInfo);
                tokens[(int)LogTokens.TS] = d;
            }
            string t = dt.ToString("T", DateTimeFormatInfo.InvariantInfo);

            tokens[(int)LogTokens.TS] += t;

            // process id
            tokens[(int)LogTokens.PId] = procId.ToString(CultureInfo.CurrentCulture);

            // thread id
            tokens[(int)LogTokens.TId] = threadId.ToString(CultureInfo.CurrentCulture);

            // module name
            tokens[(int)LogTokens.Mod] = this.moduleName;

            return(tokens);
        }
Example #2
0
 void WriteHelper(OutputCategory cat, string line)
 {
     this.WriteVerboseLog(cat, line);
     this.WriteOutputDebugString(cat, line);
     this.WriteStdOut(cat, line);
     this.WriteLog(cat, line);
 }
Example #3
0
 void WriteVerboseLog(OutputCategory cat, string line)
 {
     if ((this.outDest & OutputDestination.VerboseLog) != 0)
     {
         this.WriteLogHelper(this.logVTW, line);
     }
 }
Example #4
0
 public LogOutputItem(string message, OutputCategory category, OutputPriority priority, string outputSource = null)
 {
     this.Message      = message;
     this.Category     = category;
     this.Priority     = priority;
     this.OutputSource = outputSource;
 }
Example #5
0
        void WriteXmlLog(OutputCategory cat, string[] tokens)
        {
            if ((this.outDest & OutputDestination.XmlLog) != 0)
            {
                if (this.logXTW != null)
                {
                    lock (this.lockXmlLog)
                    {
                        this.scratchXTW.WriteStartElement("Rec");

                        for (int i = (int)LogTokens.Msg + 1; i < tokens.Length; i++)
                        {
                            if (tokens[i] != null)
                            {
                                this.scratchXTW.WriteAttributeString(
                                    ((LogTokens)i).ToString(), tokens[i]);
                            }
                        }

                        if (tokens[(int)LogTokens.Msg] != null)
                        {
                            this.scratchXTW.WriteString(tokens[(int)LogTokens.Msg]);
                        }

                        this.scratchXTW.WriteEndElement();

                        this.logXTW.WriteLine(this.scratchSW.ToString());
                        this.scratchSW.GetStringBuilder().Length = 0;
                    }
                }
            }
        }
Example #6
0
        void WriteEndMessage()
        {
            const string         epilogue = "*LOG_DONE*";
            const OutputCategory cat      = OutputCategory.Alw;

            this.WriteLine(cat, epilogue);
            this.WriteTokens(cat, epilogue);
        }
Example #7
0
        void WriteStartMessage()
        {
            const string         prologue = "*LOG_START*-";
            const OutputCategory cat      = OutputCategory.Alw;

            this.WriteLine(cat, prologue);
            this.WriteTokens(cat, prologue);
        }
 public OutputEventBody(string output, OutputCategory category = OutputCategory.Console, long?variablesReference = null, Source source = null, long?line = null, long?column = null, Dictionary <string, object> data = null)
 {
     Category           = category;
     Output             = output;
     VariablesReference = variablesReference;
     Source             = source;
     Line   = line;
     Column = column;
     Data   = data;
 }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cat"></param>
        /// <param name="msg"></param>
        /// <param name="tokens"></param>
        /// <returns></returns>
        internal string[] WriteTokens(OutputCategory cat, string msg, string[] tokens)
        {
            if (tokens[(int)LogTokens.Msg] == null)
            {
                tokens[(int)LogTokens.Msg] = msg;
            }

            tokens[(int)LogTokens.Cat] = cat.ToString();
            this.WriteHelper(cat, tokens);

            return(tokens);
        }
Example #10
0
        void WriteLog(OutputCategory cat, string line)
        {
            if ((this.outCat & cat) == 0)
            {
                return;
            }

            if ((this.outDest & OutputDestination.Log) != 0)
            {
                this.WriteLogHelper(this.logTW, line);
            }
        }
Example #11
0
        /// <summary>
        /// カテゴリ名を表す文字列を表示します。
        /// </summary>
        /// <returns>カテゴリ名。</returns>
        /// <param name="category"><see cref="Lury.Compiling.Logger.OutputCategory"/> 列挙体。</param>
        private static string GetCategoryName(OutputCategory category)
        {
            switch (category)
            {
            case OutputCategory.Error:
                return(Language.Program_Output_Error);

            case OutputCategory.Warn:
                return(Language.Program_Output_Warn);

            default:
                return(Language.Program_Output_Info);
            }
        }
Example #12
0
        void WriteStdOut(OutputCategory cat, string line)
        {
            if ((this.outCat & cat) == 0)
            {
                return;
            }

            if ((this.outDest & OutputDestination.StdOut) != 0)
            {
                // --- hack ---
                // TODO: color console hack
                // scanning for VAR_PASS, VAR_FAIL, ABORT, VAR_ABORT, GRP_ABORT
                Foreground color = Foreground.Black;

                if (line.IndexOf(OutputCategory.Alw.ToString(CultureInfo.CurrentCulture), StringComparison.CurrentCulture) != -1)
                {
                    color = Foreground.LightGreen;
                }
                else if (line.IndexOf(OutputCategory.Wrn.ToString(CultureInfo.CurrentCulture), StringComparison.CurrentCulture) != -1)
                {
                    color = color = Foreground.Yellow;
                }
                else if (line.IndexOf(OutputCategory.Err.ToString(CultureInfo.CurrentCulture), StringComparison.CurrentCulture) != -1)
                {
                    color = Foreground.LightRed;
                }
                else if (
                    //// line.IndexOf("<<<EXCEPTION>>>") != -1 ||
                    line.IndexOf("LOG_START", StringComparison.CurrentCulture) != -1 ||
                    line.IndexOf("LOG_DONE", StringComparison.CurrentCulture) != -1)
                {
                    color = Foreground.White;
                }

                lock (this.lockConsole)
                {
                    if (color != Foreground.Black)
                    {
                        ColorConsole.Write(line, color);
                        Console.WriteLine();
                    }
                    else
                    { // everything else
                        Console.WriteLine(line);
                    }
                }
                // --- end hack ---
            }
        }
Example #13
0
        void WriteOutputDebugString(OutputCategory cat, string line)
        {
            if ((this.outCat & cat) == 0)
            {
                return;
            }

            if ((this.outDest & OutputDestination.DbgOut) != 0)
            {
                lock (this.lockOutputDebug)
                {
                    OutputDebugString(line + '\r' + '\n');
                }
            }
        }
Example #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cat"></param>
        /// <param name="msg"></param>
        /// <param name="procId"></param>
        /// <param name="threadId"></param>
        /// <returns></returns>
        internal string FormatPrologEx(
            OutputCategory cat, string msg, int procId, int threadId)
        {
            if (msg == null)
            {
                throw new ArgumentNullException("Invalid parameter 'msg'");
            }

            lock (this.lockLogBuf)
            {
                // Date & Time
                DateTime dt = DateTime.Now;
                this.logBuf.Length = 0;
                this.logBuf.Append("[");
                if (this.dateOn)
                {
                    string d =
                        dt.ToString("yy-MM-dd ", DateTimeFormatInfo.InvariantInfo);
                    this.logBuf.Append(d);
                }
                string t = dt.ToString("T", DateTimeFormatInfo.InvariantInfo);
                this.logBuf.Append(t);

                this.logBuf.Append("]");

                this.logBuf.Append(" - ");

                // message body
                if (msg.Length > maxMessageLength)
                {
                    this.logBuf.Append(msg.Substring(
                                           0, maxMessageLength - Constants.TruncatedMsg.Length));
                    this.logBuf.Append(Constants.TruncatedMsg);
                }
                else
                {
                    this.logBuf.Append(msg);
                }

                return(this.logBuf.ToString());
            }
        }
        /// <summary>
        /// <para>The event indicates that the target has produced some output.</para>
        /// </summary>
        /// <param name="output">
        /// <para>The output to report.</para>
        /// </param>
        /// <param name="category">
        /// <para>The output category. If not specified, 'console' is assumed.</para>
        /// <para>Values: 'console', 'stdout', 'stderr', 'telemetry', etc.</para></param>
        /// <param name="variablesReference">
        /// <para>If an attribute 'variablesReference' exists and its value is > 0, the output contains objects which can be retrieved by passing 'variablesReference' to the 'variables' request. The value should be less than or equal to 2147483647 (2^31 - 1).</para>
        /// </param>
        /// <param name="source"><para>An optional source location where the output was produced.</para></param>
        /// <param name="line"><para>An optional source location line where the output was produced.</para></param>
        /// <param name="column"><para>An optional source location column where the output was produced.</para></param>
        /// <param name="data"><para>Optional data to report. For the 'telemetry' category the data will be sent to telemetry, for the other categories the data is shown in JSON format.</para></param>
        public static void SendOutputEvent(this ProtocolServer server,
                                           string output,
                                           OutputCategory category = OutputCategory.Console,
                                           long?variablesReference = null,
                                           Source source           = null,
                                           long?line   = null,
                                           long?column = null,
                                           Dictionary <string, object> data = null)
        {
            OutputEvent outputEvent = new OutputEvent(new OutputEvent.OutputEventBody(
                                                          output,
                                                          category,
                                                          variablesReference,
                                                          source,
                                                          line,
                                                          column,
                                                          data
                                                          ));

            server.SendMessage(outputEvent);
        }
Example #16
0
        private void Write(ISpan span, string operationName, OutputCategory category, string outputText)
        {
            ConsoleColor foregroundColor = this.colorChooser(span, operationName, category);
            var          spanId          = span.Context.SpanId;

            var formattedText = this.textFormatter(spanId, operationName, category, outputText);

            lock (Console.Out)
            {
                var prev = Console.ForegroundColor;
                Console.ForegroundColor = foregroundColor;
                try
                {
                    Console.WriteLine(formattedText);
                }
                finally
                {
                    Console.ForegroundColor = prev;
                }
            }
        }
Example #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="moduleName"></param>
        /// <param name="fileName"></param>
        /// <param name="verboseFileName"></param>
        /// <param name="outputCategory"></param>
        /// <param name="outputDestination"></param>
        ///  <param name="appendLog">true to append to log</param>
        /// <returns></returns>
        ///
        internal static Logger GetLogger(
            string moduleName,
            string fileName,
            string verboseFileName,
            bool appendLog,
            OutputCategory outputCategory,
            OutputDestination outputDestination)
        {
            Logger logger = new Logger();

            logger.Log               = fileName;
            logger.LogVerbose        = verboseFileName;
            logger.SharedWrite       = true;
            logger.OutputCategory    = outputCategory;
            logger.OutputDestination = outputDestination;
            logger.DateOn            = true;
            logger.ModuleName        = moduleName;
            logger.Append            = appendLog;
            logger.StartLogging();

            return(logger);
        }
Example #18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cat"></param>
 /// <param name="msg"></param>
 /// <returns></returns>
 internal string FormatProlog(OutputCategory cat, string msg)
 {
     return(this.FormatPrologEx(
                cat, msg, this.procId, AppDomain.GetCurrentThreadId()));
 }
Example #19
0
 /// <summary>
 /// カテゴリ名を表す文字列を表示します。
 /// </summary>
 /// <returns>カテゴリ名。</returns>
 /// <param name="category"><see cref="Lury.Compiling.Logger.OutputCategory"/> 列挙体。</param>
 private static string GetCategoryName(OutputCategory category)
 {
     switch (category)
     {
         case OutputCategory.Error:
             return Language.Program_Output_Error;
         case OutputCategory.Warn:
             return Language.Program_Output_Warn;
         default:
             return Language.Program_Output_Info;
     }
 }
Example #20
0
 internal string FormatPrologEx(
     OutputCategory cat, string msg, int procId, int threadId)
 {
     return(this._LogWriter.FormatPrologEx(cat, msg, procId, threadId));
 }
Example #21
0
        internal string WriteLine(OutputCategory cat, string line)
        {
            this._LogWriter.WriteLine(cat, line);

            return(line);
        }
Example #22
0
 internal string[] FormatPrologEx(
     OutputCategory cat, int procId, int threadId, string[] tokens)
 {
     return(this._LogWriter.FormatPrologEx(cat, procId, threadId, tokens));
 }
Example #23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cat"></param>
 /// <param name="msg"></param>
 /// <returns></returns>
 internal string[] Comment(OutputCategory cat, string msg)
 {
     this.WriteLine(cat, "// " + msg);
     return(this.WriteTokens(cat, msg));
 }
Example #24
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cat"></param>
 /// <param name="res"></param>
 /// <param name="msg"></param>
 /// <param name="tokens"></param>
 /// <returns></returns>
 internal string[] WriteResult(OutputCategory cat, ExeResult res, string msg, string[] tokens)
 {
     tokens[(int)LogTokens.Res] = res.ToString();
     return(this.WriteTokens(cat, msg, tokens));
 }
Example #25
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cat"></param>
 /// <param name="msg"></param>
 /// <returns></returns>
 internal string[] WriteTokens(OutputCategory cat, string msg)
 {
     return(this.WriteTokens(cat, msg, GetTokens()));
 }
Example #26
0
 internal string[] WriteTokens(OutputCategory cat, string msg, string[] tokens)
 {
     return(this._LogWriter.WriteTokens(cat, msg, tokens));
 }
Example #27
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cat"></param>
 /// <param name="line"></param>
 internal void WriteLine(OutputCategory cat, string line)
 {
     this.WriteHelper(cat, line);
 }
Example #28
0
 internal string[] Comment(OutputCategory cat, string msg)
 {
     return(this._LogWriter.Comment(cat, msg));
 }
Example #29
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cat"></param>
 /// <param name="res"></param>
 /// <param name="msg"></param>
 /// <param name="tokens"></param>
 /// <returns></returns>
 internal string[] WriteResult(OutputCategory cat, ExeResult res, string msg, string[] tokens)
 {
     return(this._LogWriter.WriteResult(cat, res, msg, tokens));
 }
Example #30
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cat"></param>
 /// <param name="tokens"></param>
 /// <returns></returns>
 internal string[] FormatProlog(OutputCategory cat, string[] tokens)
 {
     return(this.FormatPrologEx(
                cat, this.procId, AppDomain.GetCurrentThreadId(), tokens));
 }
Example #31
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cat"></param>
 /// <returns></returns>
 internal string[] FormatProlog(OutputCategory cat)
 {
     return(this.FormatProlog(cat, GetTokens()));
 }