3 Replies
      Latest reply on Jun 14, 2018 10:31 AM by eskimo
      AppDevVa Level 1 Level 1 (0 points)

        Hi Team,

         

        I went through WWDC 2018 video on 405_measuring_performance_using_logging and would like to replace existing logging mechanism with os_log to gain its benifits with signposts to measure performance.

         

        But there is main blocker as listed below:

        1. Current logging mechanism provides easy way to share the App logs by click of button,without need of external systems like Mac/Windows/iTune and its specific to our app resulting in minimum file size in KBs.

         

        How could we achieve this by migrating to os_log, as it logs into a common bulky sysdiagnose file?

        1.Could we wrap os_log to log to a file in App's documents folder?

        Simple sample code will be helpful, as I could not find more info on wrapping os_log.

         

        2. Could I programatically access sysdiagnose with filters of "my catogery" and export into App's local folder to share as before?

         

        Thanks a ton in Advance!

        • Re: os_log into a App's local file
          eskimo Apple Staff Apple Staff (10,235 points)

          1. Could we wrap os_log to log to a file in App's documents folder?

          Wrapping os_log is not recommended.  Specifically, it’s a bad idea to wrap os_log with a function because you undermine a lot of its smarts with regards efficiently storing constant strings.  In C-based languages you can get around this by wrapping it with a macro, but that option is not available in Swift.

          2. Could I programatically access sysdiagnose with filters of "my catogery" and export into App's local folder to share as before?

          There’s no way to do this currently, but it would make a fine enhancement request.

          FYI, and I only just learnt this myself, you don’t need to use iTunes to grab a sysdiagnose log.  You can export it via Settings > Privacy > Analytics > Analytics Data.  That doesn’t help with the file size, but it does smooth over one obstacle.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"

            • Re: os_log into a App's local file
              AppDevVa Level 1 Level 1 (0 points)

              Thank you Eskimo.

              Could you please let me know more details on "In C-based languages you can get around this by wrapping it with a macro, but that option is not available in Swift."

              Basic need is to use os_log to log to a local file instead of common file. Do we have macro that we could modify to direct it to log into local folder?

               

              export it via Settings > Privacy > Analytics > Analytics Data solves the need to connect to iTunes but the file is so huge that it cannot be sent via mail and our customers are mobile only users with no access to Mac/Windows to download and send.

               

              Thanks again!

                • Re: os_log into a App's local file
                  eskimo Apple Staff Apple Staff (10,235 points)

                  Swift does not support macros, so you can’t use that technique in Swift code.  The alternatively is to write your own function that appends the data to a log file you control.  There are serious negatives to do this, however.  Specifically, os_log was designed to deal with a high volume of logging while minimising the impact of those writes on the flash storage.

                  Share and Enjoy

                  Quinn “The Eskimo!”
                  Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                  let myEmail = "eskimo" + "1" + "@apple.com"