Comments (1)
When one is using swift-log across multiple different packages, should one use the same Logger instance across these packages or is it acceptable to use different instances?
Ultimately it is up to you and the needs of your system/application.
It may help to think about where/how you'd like to change log levels; which implies where loggers may need to be created for a subsystem. Note that creating a "new" logger with a changed log level is simply: var l = baseLogger; l.logLevel = .warn
. So some people use it like this and pass a "single" base logger around, modifying it as they go. The source
parameter can be used to identify "what module" has logged then as well (though we need more work with that parameter's default value).
Normally it is either recommended to either:
- go all-in passing the logger to all types and functions which need it
- this is the currently most widely adopted pattern I'd say
func hello(param: Param, other: Other, logger: Logger)
- OR go all-in on everyone getting their logger instance ad hoc.
- For the latter solution we currently do not have a great log handler backend which would allow changing configuration on the fly, but that's an alternative to consider.
Server side frameworks nowadays opt for the explicit logger passing. With the baggage context work there may be new patterns emerging, i.e. "context objects", but that's not entirely baked yet. The primary use of those is for distributed tracing.
APIs are likely to take the shape of: func hello(param: Param, other: Other, context: ...Context)
(and context has context.logger
which also uses the baggage
value -- which enables marrying distributed tracing and logging).
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
- Infinite recursion between deprecated API's HOT 4
- 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.