-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from UbiqueInnovation/bugfix/disable-slow-macros
replace macros by logger file
- Loading branch information
Showing
20 changed files
with
126 additions
and
299 deletions.
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
This file was deleted.
Oops, something went wrong.
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,79 @@ | ||
// | ||
// Logger.swift | ||
// UBKit | ||
// | ||
// Created by Nicolas Märki on 12.09.2024. | ||
// | ||
|
||
// LOGGER TEMPLATE FILE | ||
// Copy this file to your project, replace subsystem and category with your own values | ||
// Copying ensures that methods shadow Swift originals | ||
|
||
import Foundation | ||
import os | ||
|
||
public let Log = os.Logger(subsystem: "UBKit", category: "Default") | ||
|
||
public extension Logger { | ||
func reportError( | ||
_ message: String, file: StaticString = #file, line: UInt = #line | ||
) { | ||
UBNonFatalErrorReporter.shared | ||
.report( | ||
NSError( | ||
domain: (file.description as NSString).lastPathComponent, | ||
code: Int(line), | ||
userInfo: [NSDebugDescriptionErrorKey: message] | ||
) | ||
) | ||
Log.error("\(message)") | ||
} | ||
|
||
func reportCritical( | ||
_ message: String, file: StaticString = #file, line: UInt = #line | ||
) { | ||
UBNonFatalErrorReporter.shared | ||
.report( | ||
NSError( | ||
domain: (file.description as NSString).lastPathComponent, | ||
code: Int(line), | ||
userInfo: [NSDebugDescriptionErrorKey: message] | ||
) | ||
) | ||
Log.critical("\(message)") | ||
} | ||
} | ||
|
||
@available(*, deprecated, message: "Use Logger instead", renamed: "Log.debug") | ||
public func print( | ||
_ items: Any..., separator: String = " ", terminator: String = "\n" | ||
) { | ||
Log.debug("(\(items.map { "\($0)" }.joined(separator: separator)))") | ||
} | ||
|
||
public func assert( | ||
_ condition: @autoclosure () -> Bool, | ||
_ message: @autoclosure () -> String = String(), | ||
swiftAssertionFailure: Bool = true, | ||
file: StaticString = #file, | ||
line: UInt = #line | ||
) { | ||
if !condition() { | ||
Log.reportCritical(message(), file: file, line: line) | ||
if swiftAssertionFailure { | ||
Swift.assertionFailure() | ||
} | ||
} | ||
} | ||
|
||
public func assertionFailure( | ||
_ message: @autoclosure () -> String = String(), | ||
swiftAssertionFailure: Bool = true, | ||
file: StaticString = #file, | ||
line: UInt = #line | ||
) { | ||
Log.reportCritical("Assertion failed: \(message())") | ||
if swiftAssertionFailure { | ||
Swift.assertionFailure(message(), file: file, line: line) | ||
} | ||
} |
46 changes: 0 additions & 46 deletions
46
Sources/UBFoundation/Logging/PrintMacros+Implementation.swift
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.