Comments (4)
You didn't finish implementing your log handler, in the screenshot you paste the solution is included: @available(*, deprecated, message: "You should implement this method instead of using the default implementation")
@available(*, deprecated, message: "You should implement this method instead of using the default implementation")
public func log(level: Logger.Level,
message: Logger.Message,
metadata: Logger.Metadata?,
source: String,
file: String,
function: String,
line: UInt) {
// ...
}
you have to implement this method. It delegates to old methods for compatibility with existing LogHandler implementations which used the "old" API. This way we did not break source compat when adding the new handler APIs.
Please implement the above method and things will work as expected.
from swift-log.
Double checked, yeah this works correctly:
import Logging
@main
public struct untitled4 {
public static func main() {
LoggingSystem.bootstrap(Hello.init)
var log = Logger(label: "unique.value")
log[metadataKey: "mykey"] = "jelly"
log.error("hi")
}
}
struct Hello: LogHandler {
var metadata: Logging.Logger.Metadata = [:]
var logLevel: Logging.Logger.Level = .error
init(_ label: String) {
}
subscript(metadataKey metadataKey: String) -> Logger.Metadata.Value? {
get {
return self.metadata[metadataKey]
}
set(newValue) {
self.metadata[metadataKey] = newValue
}
}
// REQUIRED
func log(level: Logger.Level,
message: Logger.Message,
metadata: Logger.Metadata?,
source: String,
file: String,
function: String,
line: UInt) {
print("message: \(message)")
}
}
Please complete your LogHandler implementation and it'll work fine.
If there's anything else here please feel free to comment or reopen the issue
from swift-log.
Please re-open this ticket :) I will submit a PR to fix.
from swift-log.
Commented more in the PR: #249
We can't do source breaking changes like this for quite a while.
from swift-log.
Related Issues (20)
- xcodebuild DocC error with Xcode 14 HOT 24
- Update SwiftFormat version HOT 1
- Provide Test Helpers Publicly HOT 6
- Toggle verbose or off HOT 1
- Crash when using error log / Incomplete LogHandler implementation HOT 2
- MultiplexLogHandler to learn about metadata providers
- Add new Discord Logger to README HOT 2
- Make `StdioOutputStream` public HOT 1
- Supported way of accumulating metadata down the callstack HOT 9
- Logging function autoclosures aren't "rethrows" HOT 8
- Simplify logging `Error` types HOT 4
- Support advanced loghandler metadata use cases HOT 2
- Make StreamLogHandler initializers public
- How should I disclose using Swift Log in my iOS app?
- Unsupported runtime for visionOS HOT 1
- Fails to compile on Fedora 39 with Swift 5.8.1 (From repos) or official 5.9 binaries HOT 7
- PrivacyInfo Manifest HOT 2
- visionOS Compatibility HOT 1
- "Unsupported Runtime" when compiling for xrOS HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swift-log.