Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions Editor/UberLoggerEditorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,13 @@ void DrawToolbar()
ShowTimes = showTimes;
}
DrawPos.x += elementSize.x;
var showChannels = ToggleClamped(ShowChannels, "Channels", EditorStyles.toolbarButton, out elementSize);
if (showChannels != ShowChannels)
{
MakeDirty = true;
ShowChannels = showChannels;
}
DrawPos.x += elementSize.x;
var collapse = ToggleClamped(Collapse, "Collapse", EditorStyles.toolbarButton, out elementSize);
if(collapse!=Collapse)
{
Expand Down Expand Up @@ -365,15 +372,19 @@ bool ShouldShowLog(System.Text.RegularExpressions.Regex regex, LogInfo log)
/// <summary>
/// Converts a given log element into a piece of gui content to be displayed
/// </summary>
GUIContent GetLogLineGUIContent(UberLogger.LogInfo log, bool showTimes)
GUIContent GetLogLineGUIContent(UberLogger.LogInfo log, bool showTimes, bool showChannels)
{
var showMessage = log.Message;
//Make all messages single line
showMessage = showMessage.Replace(UberLogger.Logger.UnityInternalNewLine, " ");
if(showTimes)
{
showMessage = log.GetRelativeTimeStampAsString() + ": " + showMessage;
}

showMessage = string.Format("{0}{1}{2}{3}{4}",
showChannels ? "[" + log.Channel + "]" : "",
showTimes && showChannels ? " " : "",
showTimes ? log.GetRelativeTimeStampAsString() : "",
showChannels || showTimes ? " : " : "",
showMessage
);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm finding the conditional operators hard to parse here. Could we refactor into something like:
var channelMessage = showChannels ? String.Format("[{0}] : ", log.Channel : "";
var timeMessage = showTime ? log.GetRelativeTimeStampAsString() + " : " : "";
showMessage = String.Format("{0}{1}{2}". channelMessage, timeMessage, showMessage);


var content = new GUIContent(showMessage, GetIconForLog(log));
return content;
Expand Down Expand Up @@ -435,7 +446,7 @@ public void DrawLogList(float height)

foreach(var countedLog in collapsedLinesList)
{
var content = GetLogLineGUIContent(countedLog.Log, ShowTimes);
var content = GetLogLineGUIContent(countedLog.Log, ShowTimes, ShowChannels);
RenderLogs.Add(countedLog);
var logLineSize = logLineStyle.CalcSize(content);
LogListMaxWidth = Mathf.Max(LogListMaxWidth, logLineSize.x);
Expand All @@ -453,7 +464,7 @@ public void DrawLogList(float height)
{
if(ShouldShowLog(filterRegex, log))
{
var content = GetLogLineGUIContent(log, ShowTimes);
var content = GetLogLineGUIContent(log, ShowTimes, ShowChannels);
RenderLogs.Add(new CountedLog(log, 1));
var logLineSize = logLineStyle.CalcSize(content);
LogListMaxWidth = Mathf.Max(LogListMaxWidth, logLineSize.x);
Expand Down Expand Up @@ -507,7 +518,7 @@ public void DrawLogList(float height)
}

//Make all messages single line
var content = GetLogLineGUIContent(log, ShowTimes);
var content = GetLogLineGUIContent(log, ShowTimes, ShowChannels);
var drawRect = new Rect(logLineX, buttonY, contentRect.width, LogListLineHeight);
if(GUI.Button(drawRect, content, logLineStyle))
{
Expand Down Expand Up @@ -905,6 +916,7 @@ void ClearSelectedMessage()
Texture2D SmallWarningIcon;
Texture2D SmallMessageIcon;

bool ShowChannels = true;
bool ShowTimes = true;
bool Collapse = false;
bool ScrollFollowMessages = false;
Expand Down