Hi everyone. Is there some sample of tullbox:loggi...
# juul-libraries
f
Hi everyone. Is there some sample of tullbox:logging on iOS platform?
t
Unfortunately, not at this time. We don't currently use the iOS side of Tuulbox logging, though we'll be ramping up on iOS related efforts soon. So, definitely let us know if you have issues from the iOS perspective, and we'll do our best to address/help with any issues you have.
Are you performing logging from common code, or your
iosMain
(or similar) sourceset?
f
Hi Travis. I have doubts how to use the library on the iOS side. For example, how do install the AppleSystemLogger?
Copy code
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    Log.dispatcher.install(AppleSystemLogger) // ????????
    return true
  }
Or should I inject the Logger via Koin?
c
I'm not super familiar with Swift/iOS, but that looks correct to me.
Although if that's giving you troubles, it might be easier to make a Kotlin
fun configureLogging()
that includes
Log.dispatcher.install(AppleSystemLogger)
, and call that function from Swift. That way you don't have to worry about any real types crossing the language boundary.
f
Ok,
fun configureLogging()
seems work fine. So far I have the following impressions when using the logging from common code: If I call
fun configureLogging()
the Xcode console display for me the following:
Copy code
2021-10-04 16:52:52.587775-0300 Test-logging[760:161750] D/Unknown: Repository:init
Otherwise, the console does not log anything.
t
Otherwise, the console does not log anything.
Are you saying that other log calls in common code (e.g.
<http://Log.info|Log.info> { .. }
) aren't working?
f
Right. When I comment
fun configureLogging()
, log calls in commom code are not working.
c
Tuulbox Logging has no default output configured. You'll usually want to do some form of
Log.dispatcher.install(
on every platform you target.
The lack of default allows calls like
<http://Log.info|Log.info>
to be optimized away if a library using Tuulbox has a consumer that doesn't want logging.
f
Ok. I'm sorry, that is said in documentation.
If no Logger is installed, then log blocks are not called at runtime.
c
No worries 😄
f
So logging is working in iOS side, but with no tag. There is a issue open for this https://github.com/JuulLabs/tuulbox/issues/72, so I wait for it :) Just more one thing, please. Is it a good practice to use the library directly from the swift code?
c
There aren't really best practices yet, I think you're our first iOS user for Tuulbox Logging 🎉.
That said, we're having a lot of success using Tuulbox Logging in our application code directly (on Android).
But no testing has been done for calling these log statements directly from swift.