Skip to content

Commit

Permalink
Add flushMode and writeMode to FileRotationLogger
Browse files Browse the repository at this point in the history
  • Loading branch information
richardhenry committed Feb 7, 2024
1 parent 68dd1bb commit f71641d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Sources/Puppy/FileRotationLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public struct FileRotationLogger: FileLoggerable {
public var fileProtectionType: FileProtectionType?
public var isExcludedFromBackup: Bool

public let flushMode: FlushMode
public let writeMode: FileWritingErrorHandlingMode

let rotationConfig: RotationConfig
private weak var delegate: FileRotationLoggerDelegate?

Expand All @@ -25,6 +28,8 @@ public struct FileRotationLogger: FileLoggerable {
fileProtectionType: FileProtectionType? = nil,
isExcludedFromBackup: Bool = false,
rotationConfig: RotationConfig,
flushMode: FlushMode = .always,
writeMode: FileWritingErrorHandlingMode = .force,
delegate: FileRotationLoggerDelegate? = nil) throws {
self.label = label
self.queue = DispatchQueue(label: label)
Expand All @@ -42,6 +47,9 @@ public struct FileRotationLogger: FileLoggerable {
self.fileProtectionType = fileProtectionType
self.isExcludedFromBackup = isExcludedFromBackup

self.flushMode = flushMode
self.writeMode = writeMode

self.rotationConfig = rotationConfig
self.delegate = delegate

Expand All @@ -52,7 +60,7 @@ public struct FileRotationLogger: FileLoggerable {

public func log(_ level: LogLevel, string: String) {
rotateFiles()
append(level, string: string)
append(level, string: string, flushMode: flushMode, writeMode: writeMode)
rotateFiles()
}

Expand Down

0 comments on commit f71641d

Please sign in to comment.