void JumpToSource(LogStackFrame frame) { var filename = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), frame.FileName); if (System.IO.File.Exists(filename)) { //UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal(frame.FileName, frame.LineNumber); if (frame.FileName.StartsWith(Application.dataPath)) { var relativepath = "Assets" + frame.FileName.Substring(Application.dataPath.Length); var scriptAsset = AssetDatabase.LoadMainAssetAtPath(relativepath); AssetDatabase.OpenAsset(scriptAsset, frame.LineNumber); } else { var scriptAsset = AssetDatabase.LoadMainAssetAtPath(frame.FileName); AssetDatabase.OpenAsset(scriptAsset, frame.LineNumber); } } }
public LogInformation(UnityEngine.Object origin, string channel, LogLevel level, List <LogStackFrame> stackFrameList, LogStackFrame logStackFrame, object message, params object[] paramsObject) { OriginObject = origin; Channel = channel; LogLevel = level; StackFrameList = stackFrameList; var formatMessage = message as String; if (formatMessage != null) { if (paramsObject.Length > 0) { Message = System.String.Format(formatMessage, paramsObject); } else { Message = formatMessage; } } else { if (message != null) { Message = message.ToString(); } } RelativeTimeLine = XLogger.GetRelativeTime(); OriginStackFrame = logStackFrame; }
void JumpToSource(LogStackFrame frame) { var filename = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), frame.FileName); if (System.IO.File.Exists(filename)) { UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal(frame.FileName, frame.LineNumber); } }
void JumpToSource(LogStackFrame frame) { var filename = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), frame.FileName); if (System.IO.File.Exists(filename)) { string relPath = filename.Substring(Application.dataPath.Length - "Assets".Length).Replace("\\", "/"); AssetDatabase.OpenAsset(AssetDatabase.LoadAssetAtPath <TextAsset>(relPath), frame.LineNumber); } }
GUIContent GetFrameSourceGUIContent(LogStackFrame frame) { var source = GetSourceForFrame(frame); if (!String.IsNullOrEmpty(source)) { var content = new GUIContent(source); return(content); } return(null); }
static bool GetStackFramListFromUnity(ref List <LogStackFrame> stackFrameList, out LogStackFrame orginStackFrame) { stackFrameList.Clear(); orginStackFrame = null; StackTrace stackTrace = new StackTrace(true); StackFrame[] stackFrames = stackTrace.GetFrames(); bool MeetFirstIgnoredMethod = false; for (int i = stackFrames.Length - 1; i > 0; i--) { StackFrame tempStackFrame = stackFrames[i]; var method = tempStackFrame.GetMethod(); if (method.IsDefined(typeof(OnlyUnityLog), true)) { return(true); } if (!method.IsDefined(typeof(ExcludeStackTrace), true)) { UnityMethod.MethodMode mode = UnityMethod.GetMehodMode(method); bool isShowed; if (mode == UnityMethod.MethodMode.Show) { isShowed = true; } else { isShowed = false; } if (mode == UnityMethod.MethodMode.ShowFirst) { if (!MeetFirstIgnoredMethod) { MeetFirstIgnoredMethod = true; mode = UnityMethod.MethodMode.Show; } else { mode = UnityMethod.MethodMode.Hide; } } if (mode == UnityMethod.MethodMode.Show) { LogStackFrame logStackFrame = new LogStackFrame(tempStackFrame); stackFrameList.Add(logStackFrame); if (isShowed) { orginStackFrame = logStackFrame; } } } } return(false); }
void DrawFrameSource(LogStackFrame frame) { var style = new GUIStyle(GUI.skin.textArea); style.richText = true; var source = GetSourceForFrame(frame); if (!String.IsNullOrEmpty(source)) { EditorGUILayout.BeginVertical(); GUILayout.Label(source, style); EditorGUILayout.EndVertical(); } }
/// <summary> ///If the frame has a valid filename, get the source string for the code around the frame ///This is cached, so we don't keep getting it. /// </summary> string GetSourceForFrame(LogStackFrame frame) { if (SourceLinesFrame == frame) { return(SourceLines); } if (frame.FileName == null) { return(""); } var osFileName = UberLogger.Logger.ConvertDirectorySeparatorsFromUnityToOS(frame.FileName); var filename = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), osFileName); if (!System.IO.File.Exists(filename)) { return(""); } int lineNumber = frame.LineNumber - 1; int linesAround = 3; var lines = System.IO.File.ReadAllLines(filename); var firstLine = Mathf.Max(lineNumber - linesAround, 0); var lastLine = Mathf.Min(lineNumber + linesAround + 1, lines.Count()); SourceLines = ""; if (firstLine != 0) { SourceLines += "...\n"; } for (int c1 = firstLine; c1 < lastLine; c1++) { string str = lines[c1] + "\n"; if (c1 == lineNumber) { str = "<color=#ff0000ff>" + str + "</color>"; } SourceLines += str; } if (lastLine != lines.Count()) { SourceLines += "...\n"; } SourceLinesFrame = frame; return(SourceLines); }
bool JumpToSource(LogStackFrame frame) { if (frame.FileName != null) { var filename = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), frame.FileName); if (System.IO.File.Exists(filename)) { if (UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal(frame.FileName, frame.LineNumber)) { return(true); } } } return(false); }
string GetSourceForFrame(LogStackFrame frame) { if (SourceLinesFrame == frame) { return(SourceLines); } if (frame.FileName == null) { return(""); } var osFileName = XLogger.ConvertDirectorySeparatorsFromUnityToOS(frame.FileName); var filename = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), osFileName); if (!System.IO.File.Exists(filename)) { return(""); } int lineNumber = frame.LineNumber - 1; int linesAround = 3; var lines = System.IO.File.ReadAllLines(filename); var firstLine = Mathf.Max(lineNumber - linesAround, 0); var lastLine = Mathf.Min(lineNumber + linesAround + 1, lines.Length); SourceLines = ""; if (firstLine != 0) { SourceLines += "...\n"; } for (int i = firstLine; i < lastLine; i++) { string str = lines[i] + "\n"; SourceLines += str; } if (lastLine != lines.Length) { SourceLines += "...\n"; } SourceLinesFrame = frame; return(SourceLines); }
static List <LogStackFrame> GetStackFrameFromeUnity(string unityStackFrame, out LogStackFrame orginStackFrame) { var newLines = Regex.Split(unityStackFrame, UnityNewLine); List <LogStackFrame> stackFrames = new List <LogStackFrame>(); foreach (var line in newLines) { var frame = new LogStackFrame(line); if (!string.IsNullOrEmpty(frame.FormatMethodNameByFile)) { //change! stackFrames.Add(frame); } } if (stackFrames.Count > 0) { orginStackFrame = stackFrames[0]; } else { orginStackFrame = null; } return(stackFrames); }
void DrawFrameSource(LogStackFrame frame) { var style = new GUIStyle(GUI.skin.textArea); style.richText = true; var source = GetSourceForFrame(frame); if(!String.IsNullOrEmpty(source)) { EditorGUILayout.BeginVertical(); GUILayout.Label(source, style); EditorGUILayout.EndVertical(); } }
void ToggleShowSource(LogStackFrame frame) { ShowFrameSource = !ShowFrameSource; }
public StackdriverSourceLocation(LogStackFrame logStackFrame) { file = logStackFrame.FileName; line = logStackFrame.LineNumber.ToString(); function = string.Format("{0}.{1}({2})", logStackFrame.DeclaringType, logStackFrame.MethodName, logStackFrame.ParameterSig); }
GUIContent GetFrameSourceGUIContent(LogStackFrame frame) { var source = GetSourceForFrame(frame); if(!String.IsNullOrEmpty(source)) { var content = new GUIContent(source); return content; } return null; }
/// <summary> ///If the frame has a valid filename, get the source string for the code around the frame ///This is cached, so we don't keep getting it. /// </summary> string GetSourceForFrame(LogStackFrame frame) { if(SourceLinesFrame==frame) { return SourceLines; } if(frame.FileName==null) { return ""; } var filename = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), frame.FileName); if (!System.IO.File.Exists(filename)) { return ""; } int lineNumber = frame.LineNumber-1; int linesAround = 3; var lines = System.IO.File.ReadAllLines(filename); var firstLine = Mathf.Max(lineNumber-linesAround, 0); var lastLine = Mathf.Min(lineNumber+linesAround+1, lines.Count()); SourceLines = ""; if(firstLine!=0) { SourceLines += "...\n"; } for(int c1=firstLine; c1<lastLine; c1++) { string str = lines[c1] + "\n"; if(c1==lineNumber) { str = "<color=#ff0000ff>"+str+"</color>"; } SourceLines += str; } if(lastLine!=lines.Count()) { SourceLines += "...\n"; } SourceLinesFrame = frame; return SourceLines; }