This commit is contained in:
Jonathan Jenne
2019-01-23 17:22:13 +01:00
parent 1ed569f7b0
commit 94376068d6
10 changed files with 149 additions and 93 deletions

View File

@@ -111,6 +111,9 @@ Public Class LogConfig
Private Const LOG_FORMAT_EXCEPTION As String = LOG_FORMAT_BASE & " >> ${exception:format=Message}${newline}${exception:format=StackTrace}"
Private Const LOG_FORMAT_DEBUG As String = LOG_FORMAT_BASE_LONG_DATE & " >> ${message}"
Private Const FOLDER_NAME_LOG = "Log"
Private Const FILE_NAME_ACCESS_TEST = "accessTest.txt"
Private ReadOnly failSafePath As String = Path.GetTempPath()
Private ReadOnly basePath As String = failSafePath
@@ -167,11 +170,11 @@ Public Class LogConfig
If logPath = PathType.AppData Then
Dim appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
basePath = Path.Combine(appDataDir, companyName, productName)
basePath = Path.Combine(appDataDir, companyName, productName, FOLDER_NAME_LOG)
ElseIf logPath = PathType.CurrentDirectory Then
Dim currentDirectory As String = My.Application.Info.DirectoryPath
basePath = Path.Combine(currentDirectory, "Log")
basePath = Path.Combine(currentDirectory, FOLDER_NAME_LOG)
Else 'Custom Path
basePath = customLogPath
End If
@@ -188,7 +191,7 @@ Public Class LogConfig
' Try to create a file in `basePath` to check write permissions
Try
Dim fileAccessPath = Path.Combine(basePath, "accessTest.txt")
Dim fileAccessPath = Path.Combine(basePath, FILE_NAME_ACCESS_TEST)
Using fs As FileStream = File.Create(fileAccessPath)
fs.WriteByte(0)
End Using