[TIMOB-26861] Logging inside native modules not working properly
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | None |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Release 8.0.0 |
Fix Version/s | n/a |
Components | n/a |
Labels | engSchedule |
Reporter | Jan Vennemann |
Assignee | Abir Mukherjee |
Created | 2019-02-26T11:35:08.000+0000 |
Updated | 2020-11-23T17:53:05.000+0000 |
Description
There are multiple issues with logging from native modules.
*ObjC modules*
The module template uses
DebugLog
by default. This is a macro that only logs when DEBUG
is defined. However, a module is always built with the "Release" configuration which does not has DEBUG
defined. It is enabled in the "Debug" configuration but there is no way to select that during module build. The only way to enable it is to define DEBUG
in the Release configuration which would defeat the purpose of two different configurations.
NSLog
works as expected in ObjC modules.
*Swift modules*
In Swift modules no logging works at all. Neither debugPrint
, print
nor NSLog
print anything to the logs. This is somewhat expected for debugPrint
and print
since they only work with the Xcode debugger log.
For NSLog
however, the only way to get any logs is to check the Console app where log messages will appear. The default Titanium device/simulator log doesn't contain any logging made from within a Swift module with NSLog
.
[~cbarber] you are familiar with our logging, any idea why no logs appear from Swift modules?
If you prefix the log with
[DEBUG]
,[TRACE]
,[INFO]
,[WARN]
or[ERROR]
it will be displayed. The logger system expects those. Would be cool to pump Swift'sdebugLog
toDEBUG
directly.Nope, even that won't make logs appear in Swift modules. I tested all day with another module issue and the only way i could see logs from within Swift modules was to check through the Console app. I guess it has something to do with our redefinition of
NSLog
which won't be picked up by Swift. Also, there is another side effect which i suspect to be related to redefining NSLog: All output from NSLog made in third-party frameworks is completely gone. I noticed this when working with Localytics in Hyperloop. You can enable [logging](https://docs.localytics.com/dev/ios.html#troubleshooting-ios) in Localytics but won't see any logging at all, neither to the Console app nor in our Titanium log server. I'll add some reproducible code snippets when i have time.Good to know and good to be resolved! It definitely works for ObjC modules as you described, so the ticket name may include "Swift" as well.
Any news on this? or any kind of workaround?