'====================================================================
' Tracespy-to write custom debug information in a record file (developer: Lin Jian)
'====================================================================
'
Property
' TraceFileName-Record file name
'
Method
' ★ Text Writing Aspect
' WriteText-Write custom text
' Clearalltext-Erase all text
' ★ Time Recording aspect
' Settimepoint-Set time start
' Gettimespanfrominit-ask for time span (distance time start)
' Gettimespanfromprev-ask for time span (distance from last inquiry)
'
'====================================================================
Public Class Tracespy
' Record file name
Public Shared tracefilename as String = "Trace.txt"
' Beginning of time ' (initial current moment)
Private Shared inittimepoint as Long = Now.ticks
' Last Question Time point (initial current moment)
Private Shared prevtimepoint as Long = Now.ticks
' Write custom text
Public Shared Sub WRITETEXT (ByVal str as String, Optional ByVal showTime as Boolean = False)
Tracespyfilewriter.writetext (str, showTime)
End Sub
' Erase all text
Public Shared Sub Clearalltext ()
Tracespyfilewriter.clearalltext ()
End Sub
' Set time start
Public Shared Sub Settimepoint (Optional ByVal Note as String = "")
Inittimepoint = Now.ticks
Prevtimepoint = Now.ticks
Tracespyfilewriter.writetext ("Set Time start [" & Note &]. ")
End Sub
' Ask for time span (distance from time to start)
Public Shared Function Gettimespanfrominit (Optional ByVal Note as String = "") as Decimal
Prevtimepoint = Now.ticks
Dim Span as Decimal
span = CDec (prevtimepoint-inittimepoint)/10000D
Tracespyfilewriter.writetext ("Ask the time span [" & Note & "], distance from the start of the time" & span. ToString () & milliseconds. ")
return span
End Function
' Ask for time span (distance from last inquiry)
Public Shared Function Gettimespanfromprev (Optional ByVal Note as String = "") as Decimal
Dim Recttimepoint as Long = Now.ticks
Dim Span as Decimal
span = CDec (recttimepoint-prevtimepoint)/10000D
Prevtimepoint = Recttimepoint
Tracespyfilewriter.writetext ("Ask the time span [" & Note & "], the last Question Time is" & span. ToString () & milliseconds. ")
return span
End Function
End Class
Friend Class Tracespyfilewriter
Private Shared FileWriter as System.IO.StreamWriter
' Write a string to the file
Friend Shared Sub writetext (ByVal str as String, Optional ByVal showTime as Boolean = False)
If tracespy.tracefilename = String.Empty Then
Exit Sub
End If
FileWriter = New System.IO.StreamWriter (tracespy.tracefilename, True, Text.Encoding.Default)
Dim words as String
words = str
If ShowTime Then
Words &= "@" & now.tolongdatestring & "" & Now.tolongtimestring
End If
Filewriter.writeline (words)
Filewriter.close ()
End Sub
' Purge record files
Friend Shared Sub Clearalltext ()
If tracespy.tracefilename = String.Empty Then
Exit Sub
End If
FileWriter = New System.IO.StreamWriter (tracespy.tracefilename, False, Text.Encoding.Default)
Filewriter.write ("")
Filewriter.close ()
End Sub
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.