Ask a Question

Filter out events from the log

blbdt36
Contributor

Filter out events from the log

I am planning on exporting the logs of all my tests, but it shows all the events in the test.  This is very unhelpful.  I can limit them on TestComplete, but not when exporting.  How do I show only the message types I want?

 

I tried   Log.LockEvents();  and that didn't do anything

I can't use   Log.enabled = false because that would suppress ALL logging events.  I still need the errors, but not the individual keys and clicks messages.

 

Thanks

6 REPLIES 6
TanyaYatskovska
Community Manager

Re: Filter out events from the log

Hi,

 

You can try calling Log.Enabled=false inside the OnLogEvent event handler. In this case, you will block posting all events to the Test Log. However, all other types of messages (errors, messages, etc.) will be successfully posted.

Does it work for you?

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
blbdt36
Contributor

Re: Filter out events from the log

As I said initially, I can't use Log.Enabled = false.  I still need to see the errors.  I don't care about the events.

jmcpeek
Contributor

Re: Filter out events from the log

I feel the same way. I found a workaround that seems to work, although it isn't ideal. 

 

Assuming the events will almost always have Additional Text  populated, I use that to identify the system-generated log items. So I added an event handler which I applied to Events, Messages, and Warnings. When I want to manually log one of these items, I'll either not supply Additional Text, or will prefix it with a ^ (which I check for).

 

I've been using this approach for about a year and haven't found any instances where something is getting excluded that shouldn't, and everything I do want excluded has been.

 

 

function GeneralEvents_SuppressSystemLogging(Sender, LogParams)

    if len(logparams.additionaltext) > 0 then
        if aqstring.find(LogParams.additionaltext ,"^", 0, false) = -1 then
            logparams.locked = true
            GeneralEvents_SuppressSystemLogging = true
        else
            logparams.locked = false
            logparams.additionaltext = aqstring.replace(logparams.additionaltext, "^", "", false)
            GeneralEvents_SuppressSystemLogging = false
        end if
    else
        logparams.locked = false
        GeneralEvents_SuppressSystemLogging = false
    end if
end function
ashokkumareds
Contributor

Re: Filter out events from the log

Hi,

 

what tanya means it include the Log.Enabled=false inside the OnLogEvent event.

i.e. use below

 

function GeneralEvents_OnLogEvent(Sender, LogParams){
    Log.Enabled = false;
}

 

This should work for you. This can also be made sure like 

 

function GeneralEvents_OnLogEvent(Sender, LogParams){
    Log.Enabled = false;
}

function GeneralEvents_OnLogMessage(Sender, LogParams){
    Log.Enabled = true;
}

 

hope this helped

Thank you.
Ashok [[ -- If any answers helps you please give Kudos or Accept it as a solution to help others -- ]]
TanyaYatskovska
Community Manager

Re: Filter out events from the log


@blbdt36 wrote:

As I said initially, I can't use Log.Enabled = false.  I still need to see the errors.  I don't care about the events.


In this case, creating the OnLogEvent event handler will work for your needs. I recommend that you read the following articles to learn how to implement this:

"Creating Event Handlers for TestComplete Events" 

"OnLogEvent Event" 

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
AlexKaras
Community Hero

Re: Filter out events from the log

http://community.smartbear.com/t5/TestComplete-Feature-Requests/Make-it-possible-to-export-from-the-...

 

Those who are interested may participate 🙂

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
cancel
Showing results for 
Search instead for 
Did you mean: