/// <summary> /// Triggered by the runtime when a new message is added to the debug log. /// </summary> /// <param name="type">Type of the message that was added.</param> /// <param name="message">Text of the message.</param> private static void Internal_OnAdded(DebugMessageType type, string message) { if (OnAdded != null) { OnAdded(type, message); } }
protected void RaiseOnDebugMessage(DebugMessageType type, string message) { if (OnDebugMessage != null) { OnDebugMessage(this, new LogMessageEventArgs(type, message)); } }
private string CreateDebugMessage(DebugMessageType type, string extra = "") { switch (type) { case DebugMessageType.GetProgram: return(string.Format("{{\"id\":{0},\"type\":\"get-program\"}}", _outgoingMessageId++)); case DebugMessageType.StepInto: return(string.Format("{{\"id\":{0},\"type\":\"step-into\"}}", _outgoingMessageId++)); case DebugMessageType.StepOver: return(string.Format("{{\"id\":{0},\"type\":\"step-over\"}}", _outgoingMessageId++)); case DebugMessageType.StepOut: return(string.Format("{{\"id\":{0},\"type\":\"step-out\"}}", _outgoingMessageId++)); case DebugMessageType.Run: return(string.Format("{{\"id\":{0},\"type\":\"run\"}}", _outgoingMessageId++)); case DebugMessageType.EmulateResponse: return(string.Format("{{\"id\":{0},\"type\":\"emulate-response\"{1} }}", _outgoingMessageId++, extra)); case DebugMessageType.SetBreakpoint: return(string.Format("{{\"id\":{0},\"type\":\"set-breakpoint\"{1} }}", _outgoingMessageId++, extra)); case DebugMessageType.ClearBreakpoint: return(string.Format("{{\"id\":{0},\"type\":\"clear-breakpoint\"{1} }}", _outgoingMessageId++, extra)); } return(""); }
void DoSend(DebugMessageType type) { if (clientSocket != null && !clientSocket.Disconnected) { clientSocket.Send(type, sendStream.GetBuffer(), (int)sendStream.Position); } }
// '' <summary> // '' Logs the event to a console or file. Rather than use Console.WriteLine throughout the library we call LogEvent instead, which can be enabled or disabled in one step. Since Console.WriteLine is useful for debugging but also performance-heavy, we need the ability to enable/disable it at will. // '' </summary> // '' <param name="message"></param> // '' <remarks></remarks> public static void DebugMessage(string message, DebugMessageType level = DebugMessageType.InfoMessage, string caller = "", string internalException = "") { // TODO: implement the caller, for logging purposes and easy bug reporting // Warning!!! Optional parameters not supported // Warning!!! Optional parameters not supported // Warning!!! Optional parameters not supported // TODO: this can slow down the server dramatically switch (level) { case DebugMessageType.InfoMessage: Console.WriteLine(message); break; case DebugMessageType.WarningMessage: Console.WriteLine(message); break; case DebugMessageType.ErrorMessage: Console.WriteLine(message); break; case DebugMessageType.UsageMessage: // Console.WriteLine(message) break; } }
/// <summary> /// Triggered when a new entry is added in the debug log. /// </summary> /// <param name="type">Type of the message.</param> /// <param name="message">Message string.</param> private void OnEntryAdded(DebugMessageType type, string message) { // Check if compiler message or reported exception, otherwise parse it as a normal log message ParsedLogEntry logEntry = ScriptCodeManager.ParseCompilerMessage(message); if (logEntry == null) { logEntry = Debug.ParseExceptionMessage(message); } if (logEntry == null) { logEntry = Debug.ParseLogMessage(message); } ConsoleEntryData newEntry = new ConsoleEntryData(); newEntry.type = type; newEntry.callstack = logEntry.callstack; newEntry.message = logEntry.message; entries.Add(newEntry); if (DoesFilterMatch(type)) { listView.AddEntry(newEntry); filteredEntries.Add(newEntry); } }
internal void RaiseOnDebugMessage(DebugMessageType type, string message) { if (DebugMessage != null) { DebugMessage(this, new LogMessageEventArgs(type, message)); } }
public static void Log(DebugMessageType messageType, string logger, object message) { if (logger == null) { return; } var loggerManager = LogManager.GetLogger(Assembly.GetEntryAssembly() ?? Assembly.GetCallingAssembly(), logger); switch (messageType) { case DebugMessageType.Debug: loggerManager.Debug(message); break; case DebugMessageType.Info: loggerManager.Info(message); break; case DebugMessageType.Warning: loggerManager.Warn(message); break; case DebugMessageType.Error: loggerManager.Error(message); break; case DebugMessageType.IDEF0Trace: Trace.WriteLine(message); break; default: throw new ArgumentOutOfRangeException(nameof(messageType), messageType, null); } }
private void UpdateDrawMessageFilter() { draw_msg_sender_ = 0; draw_msg_type_ = 0; foreach (var item in MenuBar_Filter.DropDownItems) { if (item is ToolStripMenuItem menu) { if (menu.Checked) { switch (menu.Tag) { case DebugMessageSender sender: draw_msg_sender_ |= sender; break; case DebugMessageType type: draw_msg_type_ |= type; break; } } } } }
/// <summary> /// Logs a new message to the global debug log using the provided type. /// </summary> /// <param name="message">Message to log.</param> /// <param name="type">Type of the message to log.</param> internal static void LogMessage(object message, DebugMessageType type) { StringBuilder sb = new StringBuilder(); sb.AppendLine(message.ToString()); Internal_LogMessage(sb.ToString(), type); }
public DebugMessageInfo(DateTime date, ulong tick_us, DebugMessageSender sender, DebugMessageType type, string msg) { ThreadID = Thread.CurrentThread.ManagedThreadId; DateTime = date; TickTime = tick_us; Sender = sender; Type = type; Message = msg; }
void OnReceive(DebugMessageType type, byte[] buffer) { if (clientSocket == null || clientSocket.Disconnected) { return; } System.IO.MemoryStream ms = new System.IO.MemoryStream(buffer); System.IO.BinaryReader br = new System.IO.BinaryReader(ms); switch (type) { case DebugMessageType.CSAttach: { SendAttachResult(); } break; case DebugMessageType.CSBindBreakpoint: { CSBindBreakpoint msg = new Protocol.CSBindBreakpoint(); msg.BreakpointHashCode = br.ReadInt32(); msg.TypeName = br.ReadString(); msg.MethodName = br.ReadString(); msg.StartLine = br.ReadInt32(); msg.EndLine = br.ReadInt32(); TryBindBreakpoint(msg); } break; case DebugMessageType.CSDeleteBreakpoint: { CSDeleteBreakpoint msg = new Protocol.CSDeleteBreakpoint(); msg.BreakpointHashCode = br.ReadInt32(); ds.DeleteBreakpoint(msg.BreakpointHashCode); } break; case DebugMessageType.CSExecute: { CSExecute msg = new Protocol.CSExecute(); msg.ThreadHashCode = br.ReadInt32(); ds.ExecuteThread(msg.ThreadHashCode); } break; case DebugMessageType.CSStep: { CSStep msg = new CSStep(); msg.ThreadHashCode = br.ReadInt32(); msg.StepType = (StepTypes)br.ReadByte(); ds.StepThread(msg.ThreadHashCode, msg.StepType); } break; } }
public DebugMessageTypeViewModel(DebugMessageType model) { Model = model; var listener = new PropertyChangedEventListener(model) { (sender, e) => { RaisePropertyChanged(e.PropertyName); } }; CompositeDisposable.Add(listener); }
private void UpdateFilters(ToolStripMenuItem item) { DebugMessageType flag = (DebugMessageType)(int)item.Tag; if (item.Checked) { filters |= flag; } else { filters &= ~flag; } }
public static void DebugLog(DebugMessageType dtype, string message) { Console.ForegroundColor = ConsoleColor.Yellow; if (dtype == DebugMessageType.Warning) { Console.ForegroundColor = ConsoleColor.Cyan; } else if (dtype == DebugMessageType.Error) { Console.ForegroundColor = ConsoleColor.Magenta; } //Console.Write("[" + DateTime.Now.ToString("HH:mm:ss.ffffff") + "] "); Console.WriteLine(message); Console.ForegroundColor = ConsoleColor.White; }
public static void DebugLog(DebugMessageType dtype, string message) { Console.ForegroundColor = ConsoleColor.Yellow; if (dtype == DebugMessageType.Warning) { Console.ForegroundColor = ConsoleColor.Cyan; } else if (dtype == DebugMessageType.Error) { Console.ForegroundColor = ConsoleColor.Magenta; } //Console.Write("[" + DateTime.Now.ToString("HH:mm:ss.ffffff") + "] "); Console.WriteLine(message); Console.ForegroundColor = ConsoleColor.White; }
public static void Log(string message, DebugMessageType type = DebugMessageType.Info) { _messages.Add(message); _debugMessages.Add(new DebugMessage(message, type)); if (message.Length > _noToShow) { _startIndex = _messages.Count - _noToShow; } if (!_show) { _newMessages = true; } }
//len type msg public void Send(DebugMessageType type, byte[] buffer, int len) { if (!_ready) { return; } //timeStamp = UnityEngine.Time.realtimeSinceStartup; _sendStream.Position = 0; bw.Write(len + HEAD_SIZE); bw.Write((int)type); bw.Write(buffer, 0, len); int totalLen = (int)_sendStream.Position; RawSend(_socket, _sendBuffer, totalLen); //_socket.Send(_sendBuffer, len, SocketFlags.None); }
public static void Log(object message, DebugMessageType type = DebugMessageType.Debug) { var originalText = File.Exists(Settings.LogPath) ? File.ReadAllText(Settings.LogPath) : string.Empty; var t = new StackTrace().GetFrame(1).GetMethod().ReflectedType; var nmspc = t.Namespace + "." + t.Name; File.WriteAllText(Settings.LogPath, $"{(originalText != string.Empty ? originalText + Environment.NewLine : string.Empty)}" + $"[{(type == DebugMessageType.Debug ? "DEBUG" : "ERROR")}] " + $"[{DateTime.Now:MM-dd-yyyy}] [{DateTime.Now:hh:mm:ss}] {nmspc} => {message}"); if (type == DebugMessageType.Error) { UI.Notify(Database.NotifyHeader + "An error has occured. You can find more information in Space.log"); } }
public bool HandleMessage(MessageBase message) { DebugMessage debugMessage = (DebugMessage)message; DebugMessageType messageType = debugMessage.DebugMsgType; switch (messageType) { case DebugMessageType.BreakPointHitted: Thread.VolatileWrite(ref _debugHitSession, debugMessage.Id); DebugEventInfo debugEvent = new DebugEventInfo(debugMessage); _globalInfo.EventQueue.Enqueue(debugEvent); break; default: throw new ArgumentException(); } return(true); }
/// <summary> /// Checks if the currently active entry filter matches the provided type (the entry with the type that should be /// displayed). /// </summary> /// <param name="type">Type of the entry to check.</param> /// <returns>True if the entry with the specified type should be displayed in the console.</returns> private bool DoesFilterMatch(DebugMessageType type) { switch (type) { case DebugMessageType.Info: return(filter.HasFlag(EntryFilter.Info)); case DebugMessageType.Warning: case DebugMessageType.CompilerWarning: return(filter.HasFlag(EntryFilter.Warning)); case DebugMessageType.Error: case DebugMessageType.CompilerError: return(filter.HasFlag(EntryFilter.Error)); } return(false); }
public static void Write(DebugMessageType type, string text, bool append) { if (General.MainWindow == null) { return; } General.MainWindow.RunOnUIThread(() => { if (messages.Count + 1 > MAX_MESSAGES) { lock (messages) { messages.RemoveAt(0); } } messages.Add(new KeyValuePair <DebugMessageType, string>(type, text)); if (me != null && (me.filters & type) == type) { me.AddMessage(type, text, true, append); } }); }
public static void Write(DebugMessageType type, string text, bool append) { if (me != null && me.InvokeRequired) { me.Invoke(new Action <DebugMessageType, string, bool>(Write), new object[] { type, text, append }); } else { if (messages.Count + 1 > MAX_MESSAGES) { lock (messages) { messages.RemoveAt(0); } } messages.Add(new KeyValuePair <DebugMessageType, string>(type, text)); if (me != null && (me.filters & type) == type) { me.AddMessage(type, text, true, append); } } }
public DebugMessage(string message, DebugMessageType type) { Message = message; Type = type; if (Type == DebugMessageType.Error) { Color = Color.Red; } if (Type == DebugMessageType.Info) { Color = Color.White; } if (Type == DebugMessageType.Warning) { Color = Color.Yellow; } }
public static void ShowMessage(string message, DebugMessageType messageType) { if (!ConfigLoader.Instance.Config.IsDebugMode) { return; } if (messageType == DebugMessageType.AI && !ConfigLoader.Instance.Config.ShowAIDebug) { return; } if (messageType == DebugMessageType.Prisoner && !PrisonerRecruitment.PrisonerRecruitmentConfigLoader.Instance.Config.PrisonRecruitmentDebugEnabled) { return; } if (messageType == DebugMessageType.DeathTrack && !ConfigLoader.Instance.Config.ShowDeathTrackDebug) { return; } InformationManager.DisplayMessage(new InformationMessage(message, Color.ConvertStringToColor("#FF8F00FF"))); }
public static void EmitLog(string message, DebugMessageType type) { if (Debug._logHandler != null) { Debug._logHandler(Debug._indentStr + message, type); } if (type == DebugMessageType.Debug) { global::System.Console.WriteLine(message); } else if ((int)type < 2) { global::System.Console.Out.WriteLine(((object)type + ": ") + message); } else { global::System.Console.Error.WriteLine(((object)type + ": ") + message); } }
public static void Log(DebugMessageType messageType, string logger, RaiseDebugEventCallBack raiseEvent, object message, bool showInDebugConsole = false) { if (logger == null && !showInDebugConsole) { return; } var messageTypeStr = messageType.ToString(); var messageDataString = JsonConvert.SerializeObject(message, new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.Objects }); Log(messageType, logger, messageDataString); if (showInDebugConsole) { raiseEvent(messageTypeStr, messageDataString); } }
public static void Log(object instance, string message, DebugMessageType type = DebugMessageType.Message, [CallerFilePathAttribute] string callerFile = "") { if (!DebugMessagesEnabled) { return; } EngineObject obj = instance as EngineObject; if (type == DebugMessageType.Message) { LogMessage(message, callerFile, obj); } else if (type == DebugMessageType.Warning) { LogWarning(message, callerFile, obj); } else { LogError(message, callerFile, obj); } }
private void AddMessage(DebugMessageType type, string text, bool scroll, bool append) { text = textheaders[type] + text; if (append) { console.SelectionStart = console.TextLength; console.SelectionColor = textcolors[type]; console.AppendText(text); } else { console.SuspendLayout(); console.Text = text; console.SelectAll(); console.SelectionColor = textcolors[type]; console.Select(0, 0); console.ResumeLayout(); } if (scroll && autoscroll.Checked) { console.ScrollToCaret(); } }
/// <summary> /// Allocates and initializes a message with its type. /// </summary> /// <param name="type">The type of the message.</param> /// <returns>A <typeparamref name="DebugMessage"/> object.</returns> private static DebugMessage InitDebugMessage(DebugMessageType type) { return InitDebugMessage(type, null); }
/// <summary> /// Allocates and initializes a message with its type and message. /// </summary> /// <param name="type">The type of the message.</param> /// <param name="message">The message string.</param> /// <returns>A <typeparamref name="DebugMessage"/> object.</returns> private static DebugMessage InitDebugMessage(DebugMessageType type, string message) { DebugMessage debugMessage = new DebugMessage(); // assign current time debugMessage.Type = type; debugMessage.Time = DateTime.Now; debugMessage.Color = _color; // set context if(contextStack.Count > 0) { debugMessage.Context = contextStack.Peek(); } else { debugMessage.Context = null; } // set message if(message != null) { debugMessage.Message = message; } // set thread info debugMessage.ThreadName = Thread.CurrentThread.Name; debugMessage.ThreadId = AppDomain.GetCurrentThreadId(); return debugMessage; }
protected void RaiseOnDebugMessage(DebugMessageType type, string message) { if (OnDebugMessage != null) OnDebugMessage(this, new LogMessageEventArgs(type, message)); }
internal LogMessageEventArgs(DebugMessageType type, string msg) { Type = type; Message = msg; }
void OnReceive(DebugMessageType type, byte[] buffer) { if (clientSocket == null || clientSocket.Disconnected) { return; } System.IO.MemoryStream ms = new System.IO.MemoryStream(buffer); System.IO.BinaryReader br = new System.IO.BinaryReader(ms); switch (type) { case DebugMessageType.CSAttach: { SendAttachResult(); } break; case DebugMessageType.CSBindBreakpoint: { CSBindBreakpoint msg = new Protocol.CSBindBreakpoint(); msg.BreakpointHashCode = br.ReadInt32(); msg.IsLambda = br.ReadBoolean(); msg.NamespaceName = br.ReadString(); var typeName = br.ReadString(); msg.TypeName = String.IsNullOrWhiteSpace(msg.NamespaceName) ? typeName : msg.NamespaceName + "." + typeName; msg.MethodName = br.ReadString(); msg.StartLine = br.ReadInt32(); msg.EndLine = br.ReadInt32(); msg.Enabled = br.ReadBoolean(); msg.Condition = new BreakpointCondition(); msg.Condition.Style = (BreakpointConditionStyle)br.ReadByte(); if (msg.Condition.Style != BreakpointConditionStyle.None) { msg.Condition.Expression = br.ReadString(); } msg.UsingInfos = new UsingInfo[br.ReadInt32() + 1]; msg.UsingInfos[0] = new UsingInfo() { Alias = null, Name = msg.NamespaceName }; //当前命名空间具有最高优先级 for (int i = 1; i < msg.UsingInfos.Length; i++) { msg.UsingInfos[i] = new UsingInfo() { Alias = br.ReadString(), Name = br.ReadString() }; } TryBindBreakpoint(msg); } break; case DebugMessageType.CSSetBreakpointEnabled: { ds.SetBreakpointEnabled(br.ReadInt32(), br.ReadBoolean()); } break; case DebugMessageType.CSSetBreakpointCondition: { int bpHash = br.ReadInt32(); BreakpointConditionStyle style = (BreakpointConditionStyle)br.ReadByte(); string expression = style != BreakpointConditionStyle.None ? br.ReadString() : null; ds.SetBreakpointCondition(bpHash, style, expression); } break; case DebugMessageType.CSDeleteBreakpoint: { CSDeleteBreakpoint msg = new Protocol.CSDeleteBreakpoint(); msg.BreakpointHashCode = br.ReadInt32(); ds.DeleteBreakpoint(msg.BreakpointHashCode); } break; case DebugMessageType.CSExecute: { CSExecute msg = new Protocol.CSExecute(); msg.ThreadHashCode = br.ReadInt32(); ds.ExecuteThread(msg.ThreadHashCode); } break; case DebugMessageType.CSStep: { CSStep msg = new CSStep(); msg.ThreadHashCode = br.ReadInt32(); msg.StepType = (StepTypes)br.ReadByte(); ds.StepThread(msg.ThreadHashCode, msg.StepType); } break; case DebugMessageType.CSResolveVariable: { CSResolveVariable msg = new CSResolveVariable(); msg.ThreadHashCode = br.ReadInt32(); msg.FrameIndex = br.ReadInt32(); msg.Variable = ReadVariableReference(br); VariableInfo info; try { object res; info = ds.ResolveVariable(msg.ThreadHashCode, msg.FrameIndex, msg.Variable, out res); } catch (Exception ex) { info = VariableInfo.GetException(ex); } if (info.Type != VariableTypes.Pending) { SendSCResolveVariableResult(info); } } break; case DebugMessageType.CSResolveIndexAccess: { CSResolveIndexer msg = new CSResolveIndexer(); msg.ThreadHashCode = br.ReadInt32(); msg.FrameIndex = br.ReadInt32(); msg.Body = ReadVariableReference(br); msg.Index = ReadVariableReference(br); VariableInfo info; try { object res; info = ds.ResolveIndexAccess(msg.ThreadHashCode, msg.FrameIndex, new VariableReference { Parent = msg.Body, Parameters = new VariableReference[1] { msg.Index } }, out res); } catch (Exception ex) { info = VariableInfo.GetException(ex); } if (info.Type != VariableTypes.Pending) { SendSCResolveVariableResult(info); } } break; case DebugMessageType.CSEnumChildren: { int thId = br.ReadInt32(); int frameId = br.ReadInt32(); var parent = ReadVariableReference(br); VariableInfo[] info = null; try { info = ds.EnumChildren(thId, frameId, parent); } catch (Exception ex) { info = new VariableInfo[] { VariableInfo.GetException(ex) }; } if (info != null) { SendSCEnumChildrenResult(info); } } break; } }
public DebugMessage(DebugMessageType type, Text field, string text) { Type = type; TextField = field; Text = text; }
internal void RaiseOnDebugMessage(DebugMessageType type, string message) { if (DebugMessage != null) DebugMessage(this, new LogMessageEventArgs(type, message)); }
public DebugMessage(DebugMessageType messageType, DateTime time, string message) : this() { _type = messageType; _time = time; _message = message; }