tracer.txt

    ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
    ' WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
    ' INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
    ' OF MERCHANTABILITY AND/OR FITNESS FOR A  PARTICULAR
    ' PURPOSE.

    ' Copyright 2003. All rights reserved.
    ' Dalun Software Inc. ASP Power Widgets
    ' http://dalun.com 
    ' mail: sales@dalun.com
    ' mail: techsupport@dalun.com
    ' if you have any suggestions or requirements, please write to us.
    ' Revisions:

    ' Class Tracer 
    ' You can use this tracing class to make your ASP/VBS code more debuggable. 

    Dim objTracer

    Set objTracer = New Tracer
    objTracer.Initialize ("c:\debug.txt")

    objTracer.Trace "I am cool!"
    objTracer.Trace "The process Id is 1818."
    Set objTracer = Nothing

    Class Tracer
        Private m_strDebugFile
        Private m_objFS
        private m_objFile
        Private m_bIsInitialized

        Public Sub Class_Initialize
           m_strDebugFile = "c:\temp\trace.txt"	
           m_bIsInitialized = False
        End Sub

        Public Function Initialize(strTraceFilePath)
           If Len(strTraceFilePath) > 0 Then m_strDebugFile = strTraceFilePath    
           Set m_objFS = CreateObject("Scripting.FileSystemObject")
           Set m_objFile = m_objFS.OpenTextFile(m_strDebugFile, 8,True, 0)
           m_bIsInitialized = True
        End Function

        Public Function Trace(strInput)
           If m_bIsInitialized Then
              m_objFile.WriteLine("time:" & Now & " " & strInput)
           End if
        End Function

        Public Sub Class_Terminate
           If m_bIsInitialized Then
             m_objFile.Close
           End if

           Set m_objFile = Nothing
           Set m_objFS = Nothing
        End Sub
    End Class

Click here to go back.