-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Port MPILogger to Swift (#295)
* refactor: Port MPILogger to Swift * address CR * change nullability
- Loading branch information
1 parent
261102e
commit 7828fed
Showing
4 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// MPLogger.swift | ||
// mParticle-Apple-SDK | ||
// | ||
// Created by Brandon Stalnaker on 9/22/24. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct MPLogger { | ||
|
||
private static func MPLogger(loggerLevel: MPILogLevel, format: String, arguments: any CVarArg...) { | ||
if (MParticle.sharedInstance().logLevel.rawValue >= loggerLevel.rawValue && loggerLevel != .none) { | ||
let msg = String.localizedStringWithFormat(format, arguments) | ||
if let customLogger = MParticle.sharedInstance().customLogger { | ||
customLogger(msg) | ||
} else { | ||
NSLog("%@", msg) | ||
} | ||
} | ||
} | ||
|
||
public static func MPLogError(format: String, arguments: any CVarArg...) { | ||
MPLogger(loggerLevel: .error, format: format, arguments: arguments) | ||
} | ||
|
||
public static func MPLogWarning(format: String, arguments: any CVarArg...) { | ||
MPLogger(loggerLevel: .warning, format: format, arguments: arguments) | ||
} | ||
|
||
public static func MPLogDebug(format: String, arguments: any CVarArg...) { | ||
MPLogger(loggerLevel: .debug, format: format, arguments: arguments) | ||
} | ||
|
||
public static func MPLogVerbose(format: String, arguments: any CVarArg...) { | ||
MPLogger(loggerLevel: .verbose, format: format, arguments: arguments) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters