sketchucation logo sketchucation
    • Login
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    [Plugin] Trace Ruby messages

    Scheduled Pinned Locked Moved Plugins
    13 Posts 7 Posters 12.3k Views 7 Watching
    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.
    • TIGT Offline
      TIG Moderator
      last edited by

      @sahi said:

      :thumb: Thanks
      PS: Error a line 25 Dir.mkdirsdir >>> Dir.mkdir sdir

      It's even better as Dir.mkdir(sdir) - then you don't those kind of typo make mistakes...
      It's also the future-proof coding method - the 'without-parenthesis' method might be deprecated soon...

      TIG

      1 Reply Last reply Reply Quote 0
      • Al HartA Offline
        Al Hart
        last edited by

        @sahi said:

        :thumb: Thanks

        PS: Error a line 25 Dir.mkdirsdir >>> Dir.mkdir sdir

        AArrggh: 😡

        Thanks sahi and thanks TIG

        Al Hart

        http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
        IRender nXt from Render Plus

        1 Reply Last reply Reply Quote 0
        • S Offline
          sahi
          last edited by

          @tig said:

          ()
          It's also the future-proof coding method - the 'without-parenthesis' method might be deprecated soon...

          Thanks TIG.

          1 Reply Last reply Reply Quote 0
          • S Offline
            sahi
            last edited by

            Sometimes it is necessary to compare as was and as became
            It is possible to add here such code

             ffile1 = "c;\\tmp\\1_ruby_trace.txt"
                 if(File;;exists?(@sfile))
                   if (File;;exists?(ffile1))
                      File.delete(ffile1)
                    end
                    File.rename(@sfile, ffile1)
                 end #if ffile
            
            1 Reply Last reply Reply Quote 0
            • fredo6F Offline
              fredo6
              last edited by

              Al,

              You should make your code portable on Windows and Mac

              
              tmpdir = (RUBY_PLATFORM =~ /darwin/i) ? "/tmp" ; ENV["TEMP"]
              @sfile = File.join tmpdir, "Trace_Ruby.tmp"
              
              

              This also avoids calling mkdir (since the tmp directories always exists)

              Fredo

              1 Reply Last reply Reply Quote 0
              • Al HartA Offline
                Al Hart
                last edited by

                I'll make the change.

                The only thing I hate is that it is often difficult to find the real temp folder on Windows,

                Typing in %TEMP% in Windows Explorer will find it, but I don't know if everyone knows that.

                @unknownuser said:

                Al,

                You should make your code portable on Windows and Mac

                
                > tmpdir = (RUBY_PLATFORM =~ /darwin/i) ? "/tmp" ; ENV["TEMP"]
                > @sfile = File.join tmpdir, "Trace_Ruby.tmp"
                > 
                

                This also avoids calling mkdir (since the tmp directories always exists)

                Fredo

                Al Hart

                http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                IRender nXt from Render Plus

                1 Reply Last reply Reply Quote 0
                • Al HartA Offline
                  Al Hart
                  last edited by

                  @unknownuser said:

                  Your script is working great for me! Just that timestamp needs to be logged with each console message.

                  I made a version with an optional parameter which will show the date and time for each message.

                  The new version is in the initial post for this thread.

                  # comment one of these out to add time to traces
                  @show_time = true
                  #@show_time = false
                  

                  Here is output with timestamp:

                  Console messages from: !trace_console.rb
                  Sun May 01 23:14:29 2011
                  SketchUp Version: 8.0.4811
                  Sun May 01 23:14:29 2011: -----
                  Sun May 01 23:14:29 2011:
                  Sun May 01 23:14:29 2011: Console messages are going to c:\tmp\ruby_trace.txt
                  Sun May 01 23:14:29 2011:
                  Sun May 01 23:14:29 2011: -----

                  Al Hart

                  http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                  IRender nXt from Render Plus

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    driven
                    last edited by

                    Hi Al,

                    I've been using this on a mac since you first posted it.

                    It took a day to find the .tmp file even though I always have hidden 'off' by default.

                    so I named your script auditMac.rb, made a plugins/folder put an empty text file in it like so.

                    @sfile = "/Library/Application\ Support/Google\ SketchUp\ 8/SketchUp/plugins/audit_mac_ruby/audit.txt "

                    it works great I drop auditMac.rb in the folder when I'm not having problems and put it out when needed.

                    your script just updates from the previous, so I just pull of copies if I need a log. I also park suspect rubies in the folder if I'm trouble shooting...

                    easy to find and use

                    john

                    learn from the mistakes of others, you may not live long enough to make them all yourself...

                    1 Reply Last reply Reply Quote 0
                    • TIGT Offline
                      TIG Moderator
                      last edited by

                      Finding a suitable 'temp' folder location is easy...
                      tdir=ENV["TEMP"] tdir=ENV["TMPDIR"]if not tdir ### it's a Mac ?
                      So 'tdir' is the path to the 'temp; directory for that user...

                      To make the full path to a temporary file use...
                      tfile=File.join(tdir, tfilename)

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        dburdick
                        last edited by

                        Very nice workin indeed Al. I'm still having issues re-directing error output to the log file. It seems as though Sketchup does not use stderr for error output. I've had some success just trapping messages in the Excpetion class StandardError but this is clumsy.

                        1 Reply Last reply Reply Quote 0
                        • M Offline
                          maricanis
                          last edited by

                          Hi,

                          I'm using latest version (from may 2011) and noticed strange problem.
                          When I have plugin wxSU installed and !trace_console.rb, while Sketchup is running - no problems, and CPU usage is as expected.
                          When I try to exit Sketchup,SU window is closed but Sketchup.exe process is not finished, and it uses maximal CPU load (when checked in TaskManager).
                          ##########

                          If only one of these 2 plugins wxSU and !trace_console.rb is installed Sketchup process is ended without problems.

                          It seems that writing to text file is blocked for some reason, and trace file can't be closed.

                          I'm using SU 7.1 and 8, on Windows 7.

                          Marija

                          1 Reply Last reply Reply Quote 0
                          • 1 / 1
                          • First post
                            Last post
                          Buy SketchPlus
                          Buy SUbD
                          Buy WrapR
                          Buy eBook
                          Buy Modelur
                          Buy Vertex Tools
                          Buy SketchCuisine
                          Buy FormFonts

                          Advertisement