@@ -66,6 +66,7 @@ public final class NKLogFileManager: @unchecked Sendable {
6666
6767 public static func configure( logLevel: NKLogLevel = . normal) {
6868 shared. setConfiguration ( logLevel: logLevel)
69+ shared. createLogsFolder ( )
6970 }
7071
7172 /// Returns the file URL of the currently active log file.
@@ -101,6 +102,28 @@ public final class NKLogFileManager: @unchecked Sendable {
101102 self . currentLogDate = Self . currentDateString ( )
102103 }
103104
105+ /// Creates the "Logs" folder inside the user's Documents directory if it does not already exist.
106+ ///
107+ /// This method performs the following steps:
108+ /// - Retrieves the path to the `.documentDirectory` using `FileManager`.
109+ /// - Appends a "Logs" subdirectory path.
110+ /// - Checks if the folder already exists.
111+ /// - If not, it creates the folder, including any intermediate directories.
112+ /// - Finally, it sets the `logDirectory` and initializes the current log date.
113+ ///
114+ /// If folder creation fails, the method silently ignores the error.
115+ ///
116+ /// - Note: The `logDirectory` property will point to the created `Logs` folder.
117+ ///
118+ private func createLogsFolder( ) {
119+ let documents = FileManager . default. urls ( for: . documentDirectory, in: . userDomainMask) . first!
120+ let logsFolder = documents. appendingPathComponent ( " Logs " , isDirectory: true )
121+ if !FileManager. default. fileExists ( atPath: logsFolder. path) {
122+ try ? FileManager . default. createDirectory ( at: logsFolder, withIntermediateDirectories: true )
123+ }
124+ self . currentLogDate = Self . currentDateString ( )
125+ }
126+
104127 /// Sets configuration parameters for the logger.
105128 /// - Parameters:
106129 /// - logLevel: The NKLogLevel { disabled .. verbose }
0 commit comments