Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23241] Windows: logging from native module doesn't work

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-04-26T13:52:28.000+0000
Affected Version/sRelease 5.3.0
Fix Version/sRelease 5.4.0, Release 5.3.0
ComponentsWindows
Labelsn/a
ReporterKota Iguchi
AssigneeKota Iguchi
Created2016-04-19T22:51:10.000+0000
Updated2016-06-30T11:34:52.000+0000

Description

The C++ macros for logging (TITANIUM_LOG_DEBUG etc) shows nothing when you launch the app from Titanium CLI. That's because TITANIUM_LOG_DEBUG prints out to standard out but Titanium CLI uses different protocol (log relay: listening sockets and relays it to CLI).

Comments

  1. Kota Iguchi 2016-04-20

    I guess the easiest workaround would be to create C++ macro that just calls get_context().JSEvaluateScript("Ti.API.info(" + message + ");").
  2. Christopher Williams 2016-04-20

    Do we want different macros for logging to VS console versus to Ti.API logger? I'm concerned that just switching over to using Ti.API will mean lots of logging flowing to the CLI for our internal SDK - that we likely don't want to show whatsoever. I think there's a difference between what we want to log internally for development of the SDK versus logging to the console for module development purposes.
  3. Kota Iguchi 2016-04-21

    Makes sense. I think we need logging for module development, maybe something like TITANIUM_MODULE_LOG_DEBUG and so on.
  4. Kota Iguchi 2016-04-23

    https://github.com/appcelerator/titanium_mobile_windows/pull/642
  5. Kota Iguchi 2016-04-26

    Pushed to master, will be available in nightly build soon. // new include is required, to use new logging macros #include "TitaniumWindows/LogForwarder.hpp" // Logging macro for native module debugging: -TITANIUM_MODULE_LOG_TRACE("value: " << value);- // In the background service, you need to use this: -TITANIUM_MODULE_LOG_INFO_BACKGROUND("value: " << value);- Note that you will need to re-create module project in order to use new logging macros. It is required because we need to set new include path and library path... For more information on Windows native module development, see [Windows_Module_Development_Guide](http://docs.appcelerator.com/platform/latest/#!/guide/Windows_Module_Development_Guide).
  6. Kota Iguchi 2016-04-27

    TIMOB-23274 introduces macro argument spec changes to align with TITANIUM_LOG_INFO. Now it uses , to receive multiple parameters.
       // new include is required, to use new logging macros
       #include "TitaniumWindows/LogForwarder.hpp" 
       
       // Logging macro for native module debugging: 
       TITANIUM_MODULE_LOG_TRACE("value: ", value);
       
       // In the background service, you need to use this:
       TITANIUM_MODULE_LOG_INFO_BACKGROUND("value: ", value);
       
  7. Kota Iguchi 2016-05-23

    {quote} I believe testing this ticket as part of 5.3.0 will be blocked by bugs in 5_3_X that are fixed in master {quote} [~eharris] Do you mean you know specific ticket number for the "bugs in 5_3_X that are fixed in master"? I guess TIMOB-23246 ?
  8. Ewan Harris 2016-05-23

  9. Kota Iguchi 2016-05-23

    [~eharris] Yeah, appc has a issue building Windows module ( as I recall even on 5.4.X). For a workaround we use ti build -p windows -T ws-local for now. For more details please see [Windows Module Quick Start](http://docs.appcelerator.com/platform/latest/#!/guide/Windows_Module_Quick_Start).
  10. Kota Iguchi 2016-05-31

    Just noticed that the issue on building module using appc ti build has been fixed (TIMOB-23157) for 5_4_X. I'm not quite sure which PR makes this work though, I'll check this again and see if we can make it on 5_3_X.
  11. Kota Iguchi 2016-05-31

    I was trying to see if we can make appc ti build work with modules on 5_3_X (TIMOB-23157), and ends up finding we'll need a lot of changes to backport, such as TIMOB-23248 and TIMOB-23158 like Ewan pointed out, as well as changes in windowslib. I think it's too much for this limited time period for 5_3_X.
  12. Ewan Harris 2016-06-30

    Verified using: Windows 10 Pro Ti SDK: 5.4.0.v20160629063537 Appc NPM: 4.2.7-2 Appc CLI: 5.4.0-23 Appc Studio: 4.7.0.201606220541 Lumia 930: 10.0 Lumia 520: 8.1 Logging can now be performed using the functions below depending on the log level desired.
        TITANIUM_MODULE_LOG_TRACE("hi");
        TITANIUM_MODULE_LOG_INFO("hi");
        TITANIUM_MODULE_LOG_DEBUG("hi");
        TITANIUM_MODULE_LOG_WARN("hi");
        TITANIUM_MODULE_LOG_ERROR("hi");
        
    Closing ticket.

JSON Source