public static void Broadcast(TraceMessage message) { if (message != null) { try { var context = GlobalHost.ConnectionManager.GetConnectionContext<Connection>(); var serializer = new JavaScriptSerializer(); context.Connection.Broadcast(serializer.Serialize(new [] { message})); } catch (Exception ex) { Trace.TraceError("Broadcast Error: " + ex.ToString() + ", " +ex.StackTrace); } } }
private void ForwardTrace(string line) { Regex expr = new Regex(@"^(?<timestamp>\w+) PID\[(?<pid>\d+)\] (?<level>\w+) (?<message>\w+)$"); Match match = expr.Match(line); if (match != null) { TraceMessage trace = new TraceMessage() { ProcessId = Int32.Parse(match.Groups["pid"].Value), Message = match.Groups["timestamp"].Value, Level = ConvertLevel(match.Groups["level"].Value), Timestamp = DateTime.ParseExact(match.Groups["timestamp"].Value, "yyyy-MM-ddTHH:mm:ss.ff", CultureInfo.InvariantCulture), Category = string.Empty, EventId = 0, ThreadId = 0, Machine = "Azure Website: " + SiteName, Source = "Azure Website: " + SiteName }; } }