Public Sub prcOutputLog(ByVal strType As String, ByVal strFuncName As String, _
ByVal strErrCode As String, ByVal strErrMsg As String, ByVal strSql As String)
Dim ts As Object
Dim fso As Object
Dim dateNow As Date
Dim strProjectPath As String
Dim strLogFolderPath As String
Dim strLogFilePath As String
Dim strLogFileName As String
dateNow = Now
strLogFileName = "log_" & Format(dateNow, "yyyyMMdd") & ".log"
strProjectPath = ThisWorkbook.Path
strLogFolderPath = strProjectPath & "\Log"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(strLogFolderPath) = False Then
fso.CreateFolder (strLogFolderPath)
End If
strLogFilePath = strLogFolderPath & "\" & strLogFileName
Set ts = fso.OpenTextFile(strLogFilePath, 8, True)
Select Case strType
Case "S"
ts.WriteLine (Format(dateNow, "yyyy/MM/dd HH:nn:ss") & ";" _
& "Start;" _
& "Function;" _
& "処理を開始します")
Case "N"
ts.WriteLine (Format(dateNow, "yyyy/MM/dd HH:nn:ss") & ";" _
& "End;" _
& "Function;" _
& "処理を終了します")
Case "E"
ts.WriteLine (Format(dateNow, "yyyy/MM/dd HH:nn:ss") & ";" _
& "Err;" _
& " " & Format(dateNow, "yyyy/MM/dd HH:nn:ss") & ";" _
& "エラー発生" _
& "コード:" & strErrCode & "メッセージ:" & strErrMsg & "SQL:" & strSql)
Case "I"
ts.WriteLine (Format(dateNow, "yyyy/MM/dd HH:nn:ss") & ";" _
& "Infomation;" _
& " " & Format(dateNow, "yyyy/MM/dd HH:nn:ss") & ";" _
& "パラメータの文字列をそのまま出力")
End Select
ts.Close
Set ts = Nothing
Set fso = Nothing
Exit Sub
ErrTrap:
End Sub