bbbscarter / uberlogger Goto Github PK
View Code? Open in Web Editor NEWReplacement logging framework for Unity, with a new editor and in-game console
License: MIT License
Replacement logging framework for Unity, with a new editor and in-game console
License: MIT License
We recently upgraded from Unity 2018 to 2019.2.1. Before, when I clicked on a log, it used to go to the line in the code. Now it goes to else if(severity==LogSeverity.Error) UnityEngine.Debug.LogError(showObject);
instead
`[LogUnityOnly()]
static void ForwardToUnity(UnityEngine.Object source, LogSeverity severity, object message, params object[] par)
{
object showObject = null;
if(message!=null)
{
var messageAsString = message as string;
if(messageAsString!=null)
{
if(par.Length>0)
{
showObject = String.Format(messageAsString, par);
}
else
{
showObject = message;
}
}
else
{
showObject = message;
}
}
if(source==null)
{
if(severity==LogSeverity.Message) UnityEngine.Debug.Log(showObject);
else if(severity==LogSeverity.Warning) UnityEngine.Debug.LogWarning(showObject);
else if(severity==LogSeverity.Error) UnityEngine.Debug.LogError(showObject);
}
else
{
if(severity==LogSeverity.Message) UnityEngine.Debug.Log(showObject, source);
else if(severity==LogSeverity.Warning) UnityEngine.Debug.LogWarning(showObject, source);
else if(severity==LogSeverity.Error) UnityEngine.Debug.LogError(showObject, source);
}
}`
We are using a simple "middleman" class called CustomDebug:
`public static class CustomDebug
{
private const bool USE_UBER_LOGGER = true;
[UberLogger.StackTraceIgnore]
public static void LogWarning(string message, DebugType debugType = DebugType.Temp, UnityEngine.Object obj = null)
{
string log = "";
if (Application.isEditor)
log = $"{message} [{obj?.name}] [{debugType}]";
else
log = $"{message} [{obj?.name}] [{debugType}] [{UnityEngine.SceneManagement.SceneManager.GetActiveScene().path}] [Frame {UnityEngine.Time.frameCount}] [{System.DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")}]";
if (USE_UBER_LOGGER)
UberDebug.LogWarningChannel(obj, debugType.ToString(), log);
else
Debug.LogWarning(log, obj);
}
}`
The message display renders correctly if there only are single-line messages in it.
If there is at least one multi-line message, however, the display will not always render the bottom-most element. Example screenshot attached. Notice the dark-grey region at the bottom of the messages pane; that region should display the first line of a partially-visible log message. The bottom-most message begins displaying when the invisible section is less than 1 line of text in height.
Please put all UberLogger classes in their own namespace.
Otherwise you will get problems with bigger unity projects.
Any idea why UberLogger might be causing a TypeLoadException? My project just recently starting crashing the editor constantly leaving errors in the log similar to:
TypeLoadException: Could not load type 'UnityEngine.Networking.NetworkLobbyManager' from assembly 'UnityEngine.Networking, Version=1.0.0.0, Culture=neutral, PublicKeyToken=
null'.
Although the class it mentions that it could not load varies and is not always the same. Once I remove UberLogger from the project it runs fine =/
I am using Unity 5.5.3p2 on macOS.
Starting with Unity 2017, when you run a standalone Windows executable on a machine where the Unity editor is active, the standalone executable will connect to the editor and stream log messages to the Console feed.
The look like this in the regular console:
However, they are not formatted properly in the UberLogger console:
... UberLogger interprets the entire payload as a single message. The severity level is ignored too.
This needs both some investigation (how to handle the messages properly) and also some decisions, like, does UberLogger (or plugins) need to know whether a message is coming from a remote machine? Does UberLogger (or plugins) need the remote machine name as a separate element of LogInfo?
Currently, the editor computes the size of all message elements, and applies the size of the largest to all elements in the message view. This makes the maths for scrolling and selection easy, but it is disturbing from a presentation aspect.
One way to work around this without incurring a large performance hit would be to calculate the starting Y-offset and height of each individual element and store this in two arrays when updating the layout. Operations which used to translate between pixels and element IDs would then do weighted binary searches in these arrays to find the exact locations of elements, and use the information from the table when rendering the elements.
Would this be acceptable from a performance standpoint? Is there something particular that would need to be done to avoid lots of memory allocations/frees, like, always doubling the sizes of the arrays and never shrinking them?
With the current version of UberLogger, the callstack shown for unhandled exceptions is not very useful.
Example when I raise a NotImplementedException() deep within the codebase:
The UberLogger callstack is not helpful for diagnosing where things went wrong.
I'll look into this myself in some days.
Double Click on a Log Entry in the Unity Debug Window opens Visual Studio.
Double Click on a Log Entry in the Uber Console opens Sublime Text for me.
Can this somehow changed, so that Uber Console opens the editor which is set in the Unity Editor preferences?
Thanks for UberLogger!
I had one issue which is that making it a drop-in replacement with the global static class Debug
conflicts with several use cases for me, including dropping in the standard Unity Test Tools.
There are 2 issues I've seen and the test tools trigger both of them:
Debug.isDebugBuild
fails and I don't believe it's possible to fix that by proxying since C# doesn't allow properties on static classes, or global variables which you'd need to proxy it with an instance.using Debug = UnityEngine.Debug;
because you're also importing System.Diagnostics
conflicts with the global namespace Debug
I've fixed this in my projects by just renaming the Debug
class UberDebug
because I don't really mind that it's not a drop-in replacement and that I need to use it specifically (it's still a nice shortcut over UberLogger.Logger.Log
). I don't know if you want a PR for this though since one of the highlighted features is that it's a drop-in replacement - although sometimes it isn't if your code has either of the 2 issues above ๐ Maybe you can think of a better way to mitigate this, or maybe this could just be in the docs as a gotcha.
Thanks again!
With more than a half-dozen filters, the in-game window will flicker between rendering at two different widths: The normal console width (which is about half a screen at 1920x1080), and a greater width which is determined by the total number of buttons. This is ugly.
With lots of filters, the scrollbar is no longer usable.
Currently there are two columns in the message pane: The message type indicator column, and then the text column.
The text column contains either just the message, or it contains timestamp + message.
Formatting becomes weird when timestamps are visible, and a multiline message is printed (see screenshot).
I think it would be preferable to divide the message pane into columns like this:
This would either require a heading row for the message pane, so that the user can adjust the relative width of each column -- or the message pane would need to analyze strings as they get added, find the maximum width for each column widths, and automatically adjust the display of all message entries accordingly.
It is possible to click in the Editor's Uber Console window and mark individual messages, but there is no keyboard navigation (up-arrow/down-arrow, page up/down, home/end). I miss this a lot.
If we were to combine this with the filter window then I think the following design could work. What do you think? Suggestions welcome!
There are three views which are keyboard controllable -- the search filter input field, the list of messages, and the list of stackframes. The user should be able to switch focus (and keyboard input) between the three.
Visual representation of selection
For the filter view, there are just two styles -- active (this is when you can edit the filter string) and inactive.
For the message and stack frame views, elements can have one out of three visual presentations: not selected (today's grey), selected-but-inactive (a new, different grey), and selected-and-active (today's blue). Clicking on an entry in the message or stack frame view will move focus to that view and select the entry that was clicked on. Clicking on an entry in the other view will make the selected entry in the first view display as selected-but-inactive mode.
Keyboard navigation will change which entry in the view is currently selected; the view will scroll as needed to ensure that the entire entry is visible (or if the entry is higher than the view, the top portion of the entry should be visible).
Keyboard bindings
It should ideally be possible to navigate between the three views using the keyboard (tab + shift-tab?).
Pressing Return on a message could be used to open source file externally.
Single-clicking on an entry in the callstack view has no effect; there is double-clicking to open file externally and right-clicking to show/hide nearby code. These operations could map to space (for hiding/showing nearby code) and Return (for opening file externally).
Uber Console doesnt show compiler errors.
If I want to see the compiler errors, I have to switch to the old Unity console.
Can this be fixed?
When logging a long line, UberLogger appears to hang. On my machine, logging new string('a', 100000)
takes a bit over 3 minutes. This is due to ExtractInfoFromUnityMessage
parsing the filepath(lineno) with the UnityMessageRegex
that backtracks like crazy.
See the PR.
I would assume this would be the default behavior. Maybe I switch to turn it off. Is it intended?
The console window is currently fitting all filter buttons into a fixed-size region. This works poorly when using 10+ filters; the text on individual filter buttons gets cropped.
Suggestions to solve this:
Also, perhaps sort the buttons in alphabetical order? Makes it easier to find the one you're looking for.
For some reason, whatever you log you get a horizontal scroll bar indicating the log window can be scrolled horizontally slightly. I suspect this is a discrepancy between the manually calculated width and the actual width, caused by the icon on the left hand side.
This is easy to fix but I'm questioning whether it has been done deliberately. The UberDebug.LogChannel() methods use the Message severity level as I expect but non-channel ones use Warning. This seems odd since I have LogWarning() methods to use if I want that severity.
Code change appears to be just changing from Warning to Message in the first two methods in UberDebug.cs, can pull request if required
Sometimes this log entry appears (just in the unity console):
Register
UnityEngine.Debug:Log(Object)
UberDebug:UnityLog(Object) (at Assets/UberLogger/UberDebug.cs:85)
UberLogger.Logger:.cctor() (at Assets/UberLogger/UberLogger.cs:204)
UberLoggerEditorWindow:OnEnable() (at Assets/UberLogger/Editor/UberLoggerEditorWindow.cs:81)
UberLoggerEditorWindow:OnEnable() (at Assets/UberLogger/Editor/UberLoggerEditorWindow.cs:60)
Can this be removed?
When there are 1000+ lines visible in the window, and a new Debug.Log occurs, the Editor will hitch noticeably.
Scrolling up/down does not make it hitch. Debug.Log when most messages are filtered out (by enabling the message filter in the top-right corner of the window) does not make it hitch.
fix .it's my problem~.
When parsing an invalid linenumber in ExtractInfoFromUnityMessage to int32 Uberlogger is throwing an error. Happened with logs from the Oculus SDK for some reason. To fix this issue I just changed this line.
//lineNumber = Convert.ToInt32(firstMatch.Groups[2].Value);
int.TryParse(firstMatch.Groups[2].Value, out lineNumber);
As far as I could tell there is no support for copying/pasting from the message & stacktrace windows into the clipboard. This would also be highly useful.
Suggested designs below. UI feedback appreciated!
Always copy everything
At its simplest, pressing Ctrl-C when either the messages window or stacktrace window is active, the entire contents of the window would be copied to the clipboard (with current filter applied).
Copy 1 line or everything
A more advanced implementation would allow for different selection modes: either one entry (the currently-selected) or all. Pressing Ctrl-A would mark everything in the window, and copying when all is selected would copy the entire window contents. Performing any kind of navigation in the window when all is selected, results in just a single line being selected again.
Copy 1 line, one or more ranges, or everything
This could be taken yet further by supporting shift-click and ctrl-click to mark/unmark which entries are part of the selection. Shift-clicking is the more useful of the two; it allows for copy/pasting a range from the window.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.