Skip to content

Commit

Permalink
Changed Debug folder to DebugLog to avoid ignoring files
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeqMacaw committed Jul 10, 2019
1 parent 1a14aaf commit 1f0e2ff
Show file tree
Hide file tree
Showing 4 changed files with 440 additions and 0 deletions.
118 changes: 118 additions & 0 deletions Crowbar/Core/DebugLog/AccessedBytesDebugFile.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
Imports System.IO

Public Class AccessedBytesDebugFile

#Region "Creation and Destruction"

Public Sub New(ByVal outputFileStream As StreamWriter)
Me.theOutputFileStreamWriter = outputFileStream
End Sub

#End Region

#Region "Methods"

Public Sub WriteHeaderComment()
Dim line As String = ""

line = "// "
line += TheApp.GetHeaderComment()
Me.theOutputFileStreamWriter.WriteLine(line)
End Sub

Public Sub WriteFileSeekLog(ByVal aFileSeekLog As FileSeekLog)
Dim line As String

line = "====== File Size ======"
Me.WriteLogLine(0, line)

line = aFileSeekLog.theFileSize.ToString("N0")
Me.WriteLogLine(1, line)

line = "====== File Seek Log ======"
Me.WriteLogLine(0, line)

line = "--- Summary ---"
Me.WriteLogLine(0, line)

Dim offsetStart As Long
Dim offsetEnd As Long
offsetStart = -1
offsetEnd = -1
For i As Integer = 0 To aFileSeekLog.theFileSeekList.Count - 1
If offsetStart = -1 Then
offsetStart = aFileSeekLog.theFileSeekList.Keys(i)
End If
offsetEnd = aFileSeekLog.theFileSeekList.Values(i)

If aFileSeekLog.theFileSeekDescriptionList.Values(i).StartsWith("[ERROR] Unread bytes") Then
If i > 0 Then
line = offsetStart.ToString("N0") + " - " + (aFileSeekLog.theFileSeekList.Keys(i) - 1).ToString("N0")
Me.WriteLogLine(1, line)
End If
If aFileSeekLog.theFileSeekDescriptionList.Values(i).StartsWith("[ERROR] Unread bytes (all zeroes)") Then
line = aFileSeekLog.theFileSeekList.Keys(i).ToString("N0") + " - " + offsetEnd.ToString("N0") + " [ERROR] Unread bytes (all zeroes)"
Else
line = aFileSeekLog.theFileSeekList.Keys(i).ToString("N0") + " - " + offsetEnd.ToString("N0") + " [ERROR] Unread bytes (non-zero)"
End If
Me.WriteLogLine(1, line)
offsetStart = -1
ElseIf (i = aFileSeekLog.theFileSeekList.Count - 1) OrElse (offsetEnd + 1 <> aFileSeekLog.theFileSeekList.Keys(i + 1)) Then
line = offsetStart.ToString("N0") + " - " + offsetEnd.ToString("N0")
Me.WriteLogLine(1, line)
offsetStart = -1
End If
Next

line = "------------------------"
Me.WriteLogLine(0, line)
line = "--- Each Section or Loop ---"
Me.WriteLogLine(0, line)

offsetEnd = -1
For i As Integer = 0 To aFileSeekLog.theFileSeekList.Count - 1
offsetStart = aFileSeekLog.theFileSeekList.Keys(i)
offsetEnd = aFileSeekLog.theFileSeekList.Values(i)

line = offsetStart.ToString("N0") + " - " + offsetEnd.ToString("N0") + " " + aFileSeekLog.theFileSeekDescriptionList.Values(i)
Me.WriteLogLine(1, line)
Next

line = "========================"
Me.WriteLogLine(0, line)
End Sub

#End Region

#Region "Private Methods"

Private Sub WriteFileSeparatorLines()
Dim line As String

Me.WriteLogLine(0, "")
Me.WriteLogLine(0, "")
line = "################################################################################"
Me.WriteLogLine(0, line)
Me.WriteLogLine(0, "")
Me.WriteLogLine(0, "")
End Sub

Private Sub WriteLogLine(ByVal indentLevel As Integer, ByVal line As String)
Dim indentedLine As String = ""
For i As Integer = 1 To indentLevel
indentedLine += vbTab
Next
indentedLine += line
Me.theOutputFileStreamWriter.WriteLine(indentedLine)
Me.theOutputFileStreamWriter.Flush()
End Sub

#End Region

#Region "Data"

Private theOutputFileStreamWriter As StreamWriter

#End Region

End Class
128 changes: 128 additions & 0 deletions Crowbar/Core/DebugLog/DebugFormatModule.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
Module DebugFormatModule

Public Function FormatByteWithHexLine(ByVal name As String, ByVal value As Byte) As String
Dim line As String
line = name
line += ": "
line += value.ToString("N0")
line += " (0x"
line += value.ToString("X2")
line += ")"
Return line
End Function

Public Function FormatIntegerLine(ByVal name As String, ByVal value As Integer) As String
Dim line As String
line = name
line += ": "
line += value.ToString("N0")
Return line
End Function

Public Function FormatIntegerAsHexLine(ByVal name As String, ByVal value As Integer) As String
Dim line As String
line = name
line += ": "
line += "0x"
line += value.ToString("X8")
Return line
End Function

Public Function FormatIntegerWithHexLine(ByVal name As String, ByVal value As Integer) As String
Dim line As String
line = name
line += ": "
line += value.ToString("N0")
line += " (0x"
line += value.ToString("X8")
line += ")"
Return line
End Function

Public Function FormatLongWithHexLine(ByVal name As String, ByVal value As Long) As String
Dim line As String
line = name
line += ": "
line += value.ToString("N0", TheApp.InternalNumberFormat)
line += " (0x"
line += value.ToString("X16")
line += ")"
Return line
End Function

Public Function FormatSingleFloatLine(ByVal name As String, ByVal value As Single) As String
Dim line As String
line = name
line += ": "
line += value.ToString("N6", TheApp.InternalNumberFormat)
Return line
End Function

Public Function FormatDoubleFloatLine(ByVal name As String, ByVal value As Double) As String
Dim line As String
line = name
line += ": "
line += value.ToString("N6", TheApp.InternalNumberFormat)
Return line
End Function

Public Function FormatStringLine(ByVal name As String, ByVal value As String) As String
Dim line As String
line = name
line += ": "
line += CStr(value).TrimEnd(Chr(0))
Return line
End Function

Public Function FormatIndexLine(ByVal name As String, ByVal value As Integer) As String
Dim line As String
line = "["
line += name
line += " index: "
line += value.ToString("N0")
line += "]"
Return line
End Function

Public Function FormatVectorLine(ByVal name As String, ByVal x As Double, ByVal y As Double, ByVal z As Double) As String
Dim line As String
line = name
line += "[x,y,z]: ("
line += x.ToString("N6", TheApp.InternalNumberFormat)
line += ", "
line += y.ToString("N6", TheApp.InternalNumberFormat)
line += ", "
line += z.ToString("N6", TheApp.InternalNumberFormat)
line += ")"
Return line
End Function

Public Function FormatVectorLine(ByVal name As String, ByVal value As SourceVector) As String
Dim line As String
line = name
line += "[x,y,z]: ("
line += value.x.ToString("N6", TheApp.InternalNumberFormat)
line += ", "
line += value.y.ToString("N6", TheApp.InternalNumberFormat)
line += ", "
line += value.z.ToString("N6", TheApp.InternalNumberFormat)
line += ")"
Return line
End Function

Public Function FormatQuaternionLine(ByVal name As String, ByVal value As SourceQuaternion) As String
Dim line As String
line = name
line += "[x,y,z,w]: ("
line += value.x.ToString("N6", TheApp.InternalNumberFormat)
line += ", "
line += value.y.ToString("N6", TheApp.InternalNumberFormat)
line += ", "
line += value.z.ToString("N6", TheApp.InternalNumberFormat)
line += ", "
line += value.w.ToString("N6", TheApp.InternalNumberFormat)
line += ")"
Return line
End Function

End Module
Loading

0 comments on commit 1f0e2ff

Please sign in to comment.