Option Compare Database Dim log_file_path As String Dim debug_level As Boolean Public Function log_file() log_file = log_file_path End Function Public Sub set_debug_mode() debug_level = True End Sub Public Sub logger(ByVal origin As String, ByVal level As String, ByVal msg As String) Dim fso As Object Dim oFile As Object Dim line As String Dim new_session As Boolean new_session = False If level = "DEBUG" And Not debug_level = True Then Exit Sub Set fso = CreateObject("Scripting.FileSystemObject") If Not Len(log_file_path) > 0 Then log_file_path = CurrentProject.path & "\" & "VCS.log" Debug.Print log_file_path new_session = True If Not fso.FileExists(log_file_path) Then Set oFile = fso.CreateTextFile(log_file_path) oFile.Close End If End If Set oFile = fso.OpenTextFile(log_file_path, ForAppending) If new_session Then oFile.WriteLine ("**********************************") 'oFile.WriteBlankLines (2) line = CStr(Now) + " - " + origin + " - " + level + " - " + msg Debug.Print line oFile.WriteLine (line) oFile.Close Set fso = Nothing Set oFile = Nothing If level = "CRITICAL" Then Call err.Raise(60000, "Critical error", "Critical error occured, see the log file for more informations") End If End Sub