-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FileRotationLoggerDelegate Fix Spelling #34
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ public class FileRotationLogger: FileLogger { | |
public var maxFileSize: ByteCount = 10 * 1024 * 1024 | ||
public var maxArchivedFilesCount: UInt8 = 5 | ||
|
||
public weak var delegate: FileRotationLoggerDeletate? | ||
public weak var delegate: FileRotationLoggerDelegate? | ||
|
||
public init(_ label: String, fileURL: URL) throws { | ||
try super.init(label, fileURL: fileURL) | ||
|
@@ -37,7 +37,10 @@ public class FileRotationLogger: FileLogger { | |
let oldArchivedFileURLs = ascArchivedFileURLs(fileURL) | ||
for (index, oldArchivedFileURL) in oldArchivedFileURLs.enumerated() { | ||
let generationNumber = oldArchivedFileURLs.count + 1 - index | ||
let rotatedFileURL = oldArchivedFileURL.deletingPathExtension().appendingPathExtension("\(generationNumber)") | ||
let rotatedFileURL = oldArchivedFileURL | ||
.deletingPathExtension() | ||
.appendingPathExtension("\(generationNumber)") | ||
.appendingPathComponent(".txt") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your proposal, but I intentionally use only numeric suffixes here in order to match the general log rotation format on Linux OS(without txt extension)... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I apologize that this was in here, it wasn't intended to be here as instead work on my own fork. Should've done this spelling fix on a branch instead of my I do notice this is Linux's version of file rotation, however I think it may be more beneficial to (or at least allow to) not follow that convention. The use of the original file declaration allows developers to use names like Just something that I noticed as I would need to view logs on device instead of sharing them to a computer for viewing. If you are okay with this proposal of at least adding an option between Linux style or file suffix friendly, I am more than happy to do the work with necessary modifications when it comes time for review. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the same time, I think file rotation based on file size is either unfinished (work in progress) or not working as intended. It will only work on the first time that a max file size was reached, and then the original log file can grow without bound. At least with my own experimentation with a 10kb file max to easily test with. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Thank you for sharing your idea.
IMO, I assume it depends on the change about keeping file extension... |
||
debug("generationNumber: \(generationNumber), rotatedFileURL: \(rotatedFileURL)") | ||
if !FileManager.default.fileExists(atPath: rotatedFileURL.path) { | ||
try FileManager.default.moveItem(at: oldArchivedFileURL, to: rotatedFileURL) | ||
|
@@ -113,7 +116,7 @@ public class FileRotationLogger: FileLogger { | |
} | ||
} | ||
|
||
public protocol FileRotationLoggerDeletate: AnyObject { | ||
public protocol FileRotationLoggerDelegate: AnyObject { | ||
func fileRotationLogger(_ fileRotationLogger: FileRotationLogger, didArchiveFileURL: URL, toFileURL: URL) | ||
func fileRotationLogger(_ fileRotationLogger: FileRotationLogger, didRemoveArchivedFileURL: URL) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this!