diff --git a/src/Speckle.Sdk.Logging/LogBuilder.cs b/src/Speckle.Sdk.Logging/LogBuilder.cs index 1be798a1..f30ef86c 100644 --- a/src/Speckle.Sdk.Logging/LogBuilder.cs +++ b/src/Speckle.Sdk.Logging/LogBuilder.cs @@ -50,7 +50,7 @@ public static class LogBuilder if (speckleLogging?.File is not null) { // TODO: check if we have write permissions to the file. - var logFilePath = SpecklePathProvider.LogFolderPath(applicationAndVersion, slug); + var logFilePath = SpecklePathProvider.LogFolderPath(applicationAndVersion); logFilePath = Path.Combine(logFilePath, speckleLogging.File.Path ?? "SpeckleCoreLog.txt"); serilogLogConfiguration = serilogLogConfiguration.WriteTo.File( logFilePath, @@ -71,6 +71,13 @@ public static class LogBuilder var logger = serilogLogConfiguration.CreateLogger(); Log.Logger = logger; + logger + .ForContext("hostApplication", applicationAndVersion) + .ForContext("userApplicationDataPath", SpecklePathProvider.UserApplicationDataPath()) + .ForContext("installApplicationDataPath", SpecklePathProvider.InstallApplicationDataPath) + .Information( + "Initialized logger inside {hostApplication}/{productVersion}/{version} for user {id}. Path info {userApplicationDataPath} {installApplicationDataPath}." + ); return InitializeOtelTracing(speckleTracing, resourceBuilder); } diff --git a/src/Speckle.Sdk.Logging/Path.cs b/src/Speckle.Sdk.Logging/Path.cs index b60a59fa..66c1b28d 100644 --- a/src/Speckle.Sdk.Logging/Path.cs +++ b/src/Speckle.Sdk.Logging/Path.cs @@ -150,23 +150,13 @@ public static string BlobStoragePath(string? path = null) return EnsureFolderExists(path ?? UserSpeckleFolderPath, s_blobFolderName); } - private static string EnsureFolderExists(string basePath, string folderName) + private static string EnsureFolderExists(params string[] folderName) { - var path = System.IO.Path.Combine(basePath, folderName); + var path = System.IO.Path.Combine(folderName); Directory.CreateDirectory(path); return path; } - /// - /// Get the folder where the Speckle logs should be stored. - /// - /// Name of the application using this SDK ie.: "Rhino" - /// Public version slug of the application using this SDK ie.: "2023" - public static string LogFolderPath(string hostApplicationName, string? hostApplicationVersion) - { - return EnsureFolderExists( - EnsureFolderExists(UserSpeckleFolderPath, LOG_FOLDER_NAME), - $"{hostApplicationName}{hostApplicationVersion ?? ""}" - ); - } + internal static string LogFolderPath(string applicationAndVersion) => + EnsureFolderExists(UserSpeckleFolderPath, LOG_FOLDER_NAME, applicationAndVersion); }