https://kotlinlang.org logo
Title
f

Francis Mariano

10/04/2021, 7:24 PM
Hi everyone. Is there some sample of tullbox:logging on iOS platform?
t

travis

10/04/2021, 7:26 PM
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

Francis Mariano

10/04/2021, 7:33 PM
Hi Travis. I have doubts how to use the library on the iOS side. For example, how do install the AppleSystemLogger?
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

Cedrick Cooke

10/04/2021, 7:39 PM
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

Francis Mariano

10/04/2021, 8:01 PM
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:
2021-10-04 16:52:52.587775-0300 Test-logging[760:161750] D/Unknown: Repository:init
Otherwise, the console does not log anything.
t

travis

10/04/2021, 8:43 PM
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

Francis Mariano

10/04/2021, 9:15 PM
Right. When I comment
fun configureLogging()
, log calls in commom code are not working.
c

Cedrick Cooke

10/04/2021, 9:17 PM
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

Francis Mariano

10/04/2021, 9:23 PM
Ok. I'm sorry, that is said in documentation.
If no Logger is installed, then log blocks are not called at runtime.
c

Cedrick Cooke

10/04/2021, 9:24 PM
No worries 😄
f

Francis Mariano

10/04/2021, 9:30 PM
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

Cedrick Cooke

10/04/2021, 9:50 PM
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.