Forum Discussion
Hi,
https://support.smartbear.com/testcomplete/docs/testing-with/log/working-with/from-tests.html might provide some useful info/code samples.
Hi Alex,
Thank you for the link. I was able to generate a customized log by modifying the given sample code.
Thanks a lot everyone for their help too.
below is a peice of my script which I used to get the timestamp and the log message for each row of the test log.
# Checks the data type of the log data
if LogDataType == ldtTable:
# Obtain the total number of rows in the dataset
Num = DataSet.RowCount
for i in range(0, Num):
Row = DataSet.Rows[i]
# Obtai the time of the current row & write this to the log file
TimeVal = Row.ValueByName["Time"]
ExportFile.WriteLine(aqConvert.VarToStr(TimeVal))
# Obtain the message of the current row & write this to the log file
MsgVal = Row.ValueByName["Message"]
ExportFile.WriteLine(aqConvert.VarToStr(MsgVal))
- AlexKaras6 years agoChampion Level 3
Hi,
Thank you for sharing your solution here. Hopefully, it will help others who may have similair question.
- shantlk6 years agoContributor
Thanks everyone.
I also managed to capture the type of the message to send to sumologic. Not sure if this is the best way to do it. But works very well for me. Thought of sharing so it might be helpful for someone.
# Checks the data type of the log data
if LogDataType == ldtTable:
# Obtain the total number of rows in the dataset
Num = DataSet.RowCount
for i in range(0, Num):
Row = DataSet.Rows[i]
# Obtain the time of the current row & write this to the log file
TimeVal = Row.ValueByName["Time"]
ExportFile.WriteLine(aqConvert.VarToStr(TimeVal))
# Obtain the type of the current row & write this to the log file
TypeVal = Row.ValueByName["Type"]
if (TypeVal == 822415382):
Type = "Event"
elif (TypeVal == 990187621):
Type = "Message"
elif (TypeVal == 18446744073223342617):
Type = "Checkpoint"
elif (TypeVal == 1174736231):
Type = "Warning"
elif (TypeVal == 923080487):
Type = "Error"
ExportFile.WriteLine(Type)# Obtain the message of the current row & write this to the log file
MsgVal = Row.ValueByName["Message"]
ExportFile.WriteLine(aqConvert.VarToStr(MsgVal))--------------------------------------------
So the output looks something like this:
28/08/18 15:29:31
Event
The process "firefox" was closed.
28/08/18 15:29:32
Message
Mozilla Firefox was launched.
Related Content
Recent Discussions
- 60 minutes agoSvetaG