HISE Logo Forum
    • Categories
    • Register
    • Login

    Adding Console on Compiled Plugin For Debugging

    Scheduled Pinned Locked Moved Bug Reports
    16 Posts 6 Posters 562 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      sakorada
      last edited by

      Hi ! I tried to add Console to Compiled Plugin , but I couldn't find option in ContentType for floating-tile.
      Is it it bug or missing some?
      3130884c-243f-41a2-ae8d-91e156f5837e-image.png
      https://docs.hise.audio/ui-components/floating-tiles/hise/console.html

      1 Reply Last reply Reply Quote 0
      • Christoph HartC
        Christoph Hart
        last edited by Christoph Hart

        Yeah, the Console is not part of the codebase that is used for compiling the plugin, also all calls to Console.print() are removed.

        With a little bit of extra work you could write a file logger using the new FileSystem API though.

        S 2 Replies Last reply Reply Quote 0
        • S
          sakorada @Christoph Hart
          last edited by

          @Christoph-Hart Oh Okay ,
          Console.print() is real time debugging ,but I guess file logger is also work ;D
          Thank you

          1 Reply Last reply Reply Quote 0
          • S
            sakorada @Christoph Hart
            last edited by

            @Christoph-Hart Should HISE has File.appendText() or File.appendString() then?

            1 Reply Last reply Reply Quote 0
            • Christoph HartC
              Christoph Hart
              last edited by Christoph Hart

              Nope, you can write that functionality in HiseScript:

              /** A asynchronous file logger.
              
                  You can use this in order to log to a file. It replaces
                  Console.print and appends anything to a file on the desktop.
                  
                  The actual file writing is deferred to a timer callback,
                  so you can use it in realtime callbacks without too much
                  overhead. It handles multithreaded access gracefully, however
                  you can opt to deactivate this in order to trade in CPU spikes
                  vs. logging accuracy.
                  
                  CAUTION: Never ever leave it enabled in a real project as 
                  it will still allocate memory for storing the pending message
                  queue.
              */
              namespace FileLogger
              {
                  // Set this to false if you want to keep the file content
                  // between compilations.
                  const var CLEAR_ON_COMPILE = true;
                  
                  // Or pick a file of your choice...
                  const var logFile = FileSystem.getFolder(FileSystem.Desktop).getChildFile("Log.txt");
                  
                  const var lines = logFile.loadAsString().split("\n");
                  
                  if(CLEAR_ON_COMPILE)
                      lines.clear();
                  
                  const var pendingLines = [];
                  reg flag = false;
                  reg enabled = false;
                  
                  /** You can enable / disable the logging with this function. */
                  inline function setEnabled(state)
                  {
                      if(state != enabled)
                      {
                          enabled = state;
                          
                          if(enabled)
                              t.startTimer(30);
                          else
                              t.stopTimer();
                      }
                  }
                  
                  /** Use this function if you want to print something. */
                  inline function print(text)
                  {
                      if(enabled)
                      {
                          // This will lock the flag for the duration
                          // of this operations.
                          writeLock(flag);
                          
                          pendingLines.push(text);
                          flag = true;
                      }
                  }
              
                  const var t = Engine.createTimerObject();
                  
                  t.setTimerCallback(function()
                  {
                      if(flag)
                      {
                          // This locks the flag during a print operation
                          // You can comment out this line in order to 
                          // deactivate proper handling of multithreaded
                          // access. This will remove CPU spikes (because it
                          // will never lock, but it might cause undefined 
                          // behaviour including dropped messages at potential 
                          // crashes).
                          readLock(flag);
                          
                          flag = false;
                          lines.reserve(lines.length + pendingLines.length);
                          
                          for(e in pendingLines)
                              lines.push(e);
                          
                          pendingLines.clear();
                          logFile.writeString(lines.join("\n"));
                          
                          // This will check whether there is a race condition
                          // Try to comment out the lock statement above and it will
                          // fire as soon as there is a concurrent access to 
                          // the flag (eg. if the print command is being called
                          // in a MIDI callback.
                          if(flag)
                              Console.print("RACE!");
                      }
                  });
                  
                  // Enable it by default. You can call this method from a UI element.
                  // If it's disabled it will produce almost no overhead. The rules of
                  // never creating any Strings in a realtime thread still applies 
                  // obviously...
                  setEnabled(true);
              };
              
              S SimonS 2 Replies Last reply Reply Quote 1
              • S
                sakorada @Christoph Hart
                last edited by

                @Christoph-Hart Wow , Thank you.
                I will add this to my project now ,

                1 Reply Last reply Reply Quote 0
                • SimonS
                  Simon @Christoph Hart
                  last edited by Simon

                  @Christoph-Hart I'm considering leaving this in a finished plugin, and toggling it with a debug switch in the UI settings, so I can instruct users to send me debug logs if need be. Your warning is only about extra memory usage but the all caps CAUTION is a little scary, do you anticipate anything catastrophic happening if I do?

                  d.healeyD LindonL 2 Replies Last reply Reply Quote 0
                  • d.healeyD
                    d.healey @Simon
                    last edited by

                    @Simon There is a built in debug mode that writes to a log file, would that do?

                    Libre Wave - Freedom respecting instruments and effects
                    My Patreon - HISE tutorials
                    YouTube Channel - Public HISE tutorials

                    SimonS 1 Reply Last reply Reply Quote 0
                    • SimonS
                      Simon @d.healey
                      last edited by

                      @d-healey ........ I had no idea, you learn something new every day!

                      d.healeyD 1 Reply Last reply Reply Quote 0
                      • d.healeyD
                        d.healey @Simon
                        last edited by

                        @Simon https://docs.hise.dev/scripting/scripting-api/settings/index.html#setenabledebugmode

                        Libre Wave - Freedom respecting instruments and effects
                        My Patreon - HISE tutorials
                        YouTube Channel - Public HISE tutorials

                        SimonS 1 Reply Last reply Reply Quote 0
                        • SimonS
                          Simon @d.healey
                          last edited by

                          Yes I found it, but I have yet to figure out what it does or how it works.

                          d.healeyD 1 Reply Last reply Reply Quote 0
                          • d.healeyD
                            d.healey @Simon
                            last edited by

                            @Simon https://docs.hise.dev/working-with-hise/settings/development.html#enable-debug-mode

                            Libre Wave - Freedom respecting instruments and effects
                            My Patreon - HISE tutorials
                            YouTube Channel - Public HISE tutorials

                            SimonS 1 Reply Last reply Reply Quote 0
                            • SimonS
                              Simon @d.healey
                              last edited by

                              Poked around in the source code, haven't figured out where the log is created, nor whether or how I can print messages to it. As the fileLogger is already set up I'll stick with that.

                              1 Reply Last reply Reply Quote 1
                              • LindonL
                                Lindon @Simon
                                last edited by

                                @Simon isnt this what the new profiler is for?

                                HISE Development for hire.
                                www.channelrobot.com

                                SimonS 1 Reply Last reply Reply Quote 0
                                • SimonS
                                  Simon @Lindon
                                  last edited by

                                  @Lindon Does the profiler print custom messages to an external file that I can optionally ask the user to enable and send to me if they have a strange behavior in a particular DAW?

                                  HISEnbergH 1 Reply Last reply Reply Quote 0
                                  • HISEnbergH
                                    HISEnberg @Simon
                                    last edited by

                                    @Simon It will do precisely this. There needs to be a few fixes before its ready for release builds however.

                                    1 Reply Last reply Reply Quote 1
                                    • First post
                                      Last post

                                    7

                                    Online

                                    1.7k

                                    Users

                                    11.8k

                                    Topics

                                    103.1k

                                    Posts