Announcement

Collapse
No announcement yet.

How to read the log from within a script?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to read the log from within a script?

    Rover includes a page to display and clear the log that is trimmed down slightly for consumption on a slow connection, handheld, etc. Back in HomeSeer v1.x this was done with some hideously ugly kluges. To wit, I had HomeSeer ask itself for its own Log web page, then parsed out the bits I needed. (Since this happened server-side, it didn't cause slowdowns on slow connections.) The code looked like this:

    Code:
      ' show the log, by asking HomeSeer to talk to itself, and then listening in on its conversation
      ' This is a hideous kluge!  But still kinda cute.
      if hs.Version > "1.6.110" then
          s = hs.GetURL("127.0.0.1","/elog",FALSE,hs.GetINISetting("Settings","svrport",80))
        else ' work around a syntax bug
          s = hs.GetURL("127.0.0.1:" & hs.GetINISetting("Settings","svrport",80),"/elog",FALSE,hs.GetINISetting("Settings","svrport",80))
        end if
      i = instr(lcase(s),"<pre>")
      if i <> 0 then s = mid(s,i) else s = "&lt;pre&gt;" & s
      i = instr(lcase(s),"&lt;/pre&gt;")
      if i <> 0 then s = left(s,i+5) else s = s & "&lt;/pre&gt;"
      response.write s
    This is (thankfully, perhaps!) not working in HS2, but even if it did, parsing out the log from the /elog page would be a trial and a half.

    But looking through the help file I can't see anything in the script interface that allows you to read the log. Is it in there and I can't find it? Please help. (If it isn't, can we please consider that for a future version?)
    Last edited by Hunter Green; February 18, 2006, 10:24 AM. Reason: Stupid handling of HTML in code samples
    News, support, and updates for Rover, Network Monitor, TimeIcons, and more

    #2
    Hunter,
    The log is just a text file and can be parsed using the File System Object or the newer StreamReader Class in .net.
    💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

    Comment


      #3
      That's what I was using in Rover v1 at first, but it seemed even more brittle and klugey than the GetURL approach.
      News, support, and updates for Rover, Network Monitor, TimeIcons, and more

      Comment


        #4
        Originally posted by Hunter Green
        That's what I was using in Rover v1 at first, but it seemed even more brittle and klugey than the GetURL approach.
        How in the world can a direct connection to a text file be "brittle and kludgey"? This method is being used in hundreds of thousand applications today.
        💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

        Comment


          #5
          Because the location, filename, and internal format of the log can change from release to release, have changed in the past, and surely will change again. Half the point of an API is to protect scripts from such changes as much as is feasible. That's why we don't access any other part of HomeSeer's data directly, including devices, events, INI settings, etc. If it makes sense in the other 99% of HomeSeer, why not here, too?

          In any case, Rover v2 is using this approach again, warts and all.
          News, support, and updates for Rover, Network Monitor, TimeIcons, and more

          Comment


            #6
            Originally posted by Hunter Green
            Because the location, filename, and internal format of the log can change from release to release, have changed in the past, and surely will change again. Half the point of an API is to protect scripts from such changes as much as is feasible. That's why we don't access any other part of HomeSeer's data directly, including devices, events, INI settings, etc. If it makes sense in the other 99% of HomeSeer, why not here, too?

            In any case, Rover v2 is using this approach again, warts and all.

            Hunter the format of the log file has only changed once and that was when HS was rewritten? They do not change this on a delay to delivery bases. The log file name is available in the setting.ini file gLogName=HomeSeer.LOG and the location is in the HS root folder unless gLogDir=True then it's in the Logs folder.
            💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

            Comment


              #7
              I just did a quick test with this code for my set-up:

              PHP Code:
              Sub main()
              Dim s
              hs.GetURL("http://127.0.0.1:8080","/elog",FALSE,80)
              msgbox s
              end sub 
              It returned the page with no problems but full of HTML code as expected.
              Jon

              Comment


                #8
                Jon,
                I believe Hunter reformats the data to make it more readable and that's where the problems arise.
                💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                Comment


                  #9
                  So the pre-1.6.110 bug in how port numbers is handled is back into GetURL? That's funny!

                  I'm using the INI settings Rupp pointed out to get to the file contents in beta 3. I doubt I'll go back to the GetURL approach since at least I'm protected against file name and location changing now.
                  News, support, and updates for Rover, Network Monitor, TimeIcons, and more

                  Comment


                    #10
                    Actually, the bigger difference is that using the file shows what's in the file, and the GetURL approach shows what's in memory. You didn't realize those are different?
                    News, support, and updates for Rover, Network Monitor, TimeIcons, and more

                    Comment


                      #11
                      Originally posted by Hunter Green
                      So the pre-1.6.110 bug in how port numbers is handled is back into GetURL? That's funny!
                      Remember we're on .net now. A few things have been fixed since 1.6
                      💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                      Comment


                        #12
                        hey everyone i was if there is a way to read my log and if there is a warming or a error it would say something on the lines of Error then it would read the error?

                        ~Ghost~

                        Comment


                          #13
                          Here's one way.
                          http://board.homeseer.com/showthread...405#post646405
                          Last edited by Rupp; July 18, 2011, 08:15 AM.
                          💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                          Comment


                            #14
                            Originally posted by Rupp View Post
                            I think you need to repost the link Rupp!
                            Jon

                            Comment


                              #15
                              Yes, I fixed the link. Thanks for the heads up.
                              💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                              Comment

                              Working...
                              X