Example #1
0
        private void LogMessage(DateTime timeStamp, string message)
        {
            const string LineEnd = "\r";

            if (string.IsNullOrWhiteSpace(message))
            {
                message = "no message";
            }
            message = message.Replace("\n", LineEnd);
            message = message.Replace(LineEnd + LineEnd, LineEnd);
            while (message.EndsWith(LineEnd))
            {
                message = message.Substring(0, message.Length - 1);
            }
            string text = _logMessagePrefix + timeStamp.ToString() + ": " + message;

            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { LogArea.AppendText(text); }));
            if (/*no embedded line end(s)?*/ message.IndexOf(LineEnd) < 0)
            {
                _logMessagePrefix = LineEnd;
            }
            else /*complex message; next time add blank line*/
            {
                _logMessagePrefix = LineEnd + LineEnd;
            }
        }
Example #2
0
 protected void AddLogLine(string text)
 {
     LogArea.AppendText(string.Format("{0}\r\n", text));
 }