Hi!
In FileRotationLogger.swift the function rotateFiles() fails at line 109 during the following instruction:
try FileManager.default.moveItem(at: fileURL, to: archivedFileURL)
This happens because in Formatter.swift the function dateFormatter(_:, locale:, dateFormat:, timeZone:) creates a timestamp that includes colons (:) which the file system does not like.
One potential solution is changing the dateFormat in line 13 of Formatter.swift from "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" to "yyyy-MM-dd'T'HH-mm-ss.SSS". This removes the explicit colons in the original date format string, as well as an implicit colon which is added by ZZZZZ which expands to an HH:MM style presentation of the timezone.
You might also consider reducing the complexity of this string further, since I'd argue if a detailed timestamp is necessary then it can be placed inside the log file, rather than in the file name.
One alternative could be to structure like this:
myLog.log
myLog.log.1
myLog.log.2
This proposal would simplify the implementation of the rest of the rotateFiles method that is concerned with removing old archived files.
Hi!
In
FileRotationLogger.swiftthe functionrotateFiles()fails at line 109 during the following instruction:This happens because in
Formatter.swiftthe functiondateFormatter(_:, locale:, dateFormat:, timeZone:)creates a timestamp that includes colons (:) which the file system does not like.One potential solution is changing the
dateFormatin line 13 ofFormatter.swiftfrom"yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"to"yyyy-MM-dd'T'HH-mm-ss.SSS". This removes the explicit colons in the original date format string, as well as an implicit colon which is added byZZZZZwhich expands to anHH:MMstyle presentation of the timezone.You might also consider reducing the complexity of this string further, since I'd argue if a detailed timestamp is necessary then it can be placed inside the log file, rather than in the file name.
One alternative could be to structure like this:
This proposal would simplify the implementation of the rest of the
rotateFilesmethod that is concerned with removing old archived files.