- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- v2.25.0
- v2.24.7
- v2.24.6
- v2.24.5
- v2.24.4
- v2.24.3
- v2.24.2
- v2.24.1
- v2.24.0
- v2.23.0
- v2.22.1
- v2.22.0
- v2.21.0
- v2.20.5
- v2.20.4
- v2.20.3
- v2.20.2
- v2.20.1
- v2.20.0
- v2.19.0
- v2.18.0
- v2.17.1
- v2.17.0
- v2.16.1
- v2.16.0
- v2.15.3
- v2.15.2
- v2.15.1
- v2.15.0
- v2.14.3
- v2.14.2
- v2.14.1
- v2.14.0
- v2.13.9
- v2.13.8
- v2.13.7
- v2.13.6
- v2.13.5
- v2.13.4
- v2.13.3
- v2.13.2
- v2.13.1
- v2.13.0
- v2.12.0
- v2.11.0
- v2.10.1
- v2.10.0
- v2.9.0
- v2.8.5
- v2.8.4
- v2.8.3
- v2.8.2
- v2.8.1
- v2.8.0
- v2.7.0
- v2.6.0
- 2.5.1
- 2.5.0
- 2.4.0
- 2.3.1
- 2.3.0
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0.0
Showing
4 changed files
with
53 additions
and
3 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 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,36 @@ | ||
// | ||
// Logger.swift | ||
// | ||
// | ||
// Created by Guilherme Souza on 11/12/23. | ||
// | ||
|
||
import ConcurrencyExtras | ||
import Foundation | ||
|
||
private let _debugLoggingEnabled = LockIsolated(false) | ||
@_spi(Internal) public var debugLoggingEnabled: Bool { | ||
get { _debugLoggingEnabled.value } | ||
set { _debugLoggingEnabled.setValue(newValue) } | ||
} | ||
|
||
private let standardError = LockIsolated(FileHandle.standardError) | ||
@_spi(Internal) public func debug( | ||
_ message: @autoclosure () -> String, | ||
function: String = #function, | ||
file: String = #file, | ||
line: UInt = #line | ||
) { | ||
assert( | ||
{ | ||
if debugLoggingEnabled { | ||
standardError.withValue { | ||
let logLine = "[\(function) \(file.split(separator: "/").last!):\(line)] \(message())\n" | ||
$0.write(Data(logLine.utf8)) | ||
} | ||
} | ||
|
||
return true | ||
}() | ||
) | ||
} |