Forum Discussion

pmartin66's avatar
pmartin66
Occasional Contributor
8 years ago
Solved

Capturing the internal event logs to export them at runtime to external log

Is it possible for me to get to and print out all the 'Additional Information' logged with actions in TestComplete so I can log it to my logger?

The idea is simple, a user runs tests and they fail, they can send me ONE text log file to analyze. Looking at mht files is lame and REQUIRES Internet Explorer, which I do not use.

 

As it is, my python logger gets most stuff with proper exception handling. It would be nice if I could get to the actual TC log and log it as well in python for one easy log file to analyze.

 

Any help would be appreciated.

  • The other way to do it would be to utilize the event handlers for the built in TestComplete log (OnLogError, OnLogWarning, OnLogMessage, OnLogEvent, etc).  Within those event handlers, you could write code which, in real-time, would update whatever file you want to.

     

    In each event handler, there's a parameter called LogParams that contains information about what is being logged.  On that object, there's an "AdditonalText" property that, for the log record being written, contains that Additional Info stuff.  So, on the event handler, you could write code to do a WriteLine to a text file containing the Additional Text. 

9 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    You could try exporting to unpacked file instead of to mht.

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      The other way to do it would be to utilize the event handlers for the built in TestComplete log (OnLogError, OnLogWarning, OnLogMessage, OnLogEvent, etc).  Within those event handlers, you could write code which, in real-time, would update whatever file you want to.

       

      In each event handler, there's a parameter called LogParams that contains information about what is being logged.  On that object, there's an "AdditonalText" property that, for the log record being written, contains that Additional Info stuff.  So, on the event handler, you could write code to do a WriteLine to a text file containing the Additional Text. 

      • pmartin66's avatar
        pmartin66
        Occasional Contributor

        Thank you SO MUCH for your help. I think you have pointed me in the right direction. However, when I set my 'GeneralEvents_OnLogCheckPoint' function, it doesn't work. I think I am doing something wrong.

        def GeneralEvents_OnLogCheckPoint(Sender, LogParams):

           logger = startLog('Some Log Name.GeneralEvents_OnLogCheckpoint')
           logger.info(LogParams.MessageText)
           logger.info(LogParams.AdditionalText)

         

        that function gets hit when I start my test, but the code under it never does.... hmmmm do I have to do anything special to reference the OnLogCheckPoint event properly from my script?

         

        Thanks so much for your help so far, it did work for other event handlers, not like I expected but I just need to figure it all out.