Problem implementing IReportLogger

Class library usage, coding and language questions.
rostamizadeh
Posts: 3
Joined: Thu Mar 27, 2014 10:44 pm

Problem implementing IReportLogger

Post by rostamizadeh » Mon Apr 14, 2014 3:39 pm

Hi - I've been trying to write a custom logger to save results to a postgres database. Almost everything is working as expected but I have run into a couple problems I'm hoping you can help me with.

Ranorex 5.0.1.17706
Windows 7 x64

I have both LogText() and LogData() methods included in my class, but it seems that LogData is never called.
public void LogData(Ranorex.ReportLevel level, string category, string message, object data, System.Collections.Generic.IDictionary<string, string> metaInfos)
I've set breakpoints inside this method and they are never hit.

In my program.cs, I believe I've attached my logger class correctly:
DatabaseLogger databaseLogger = new DatabaseLogger();
Report.Setup( ReportLevel.Debug, "report.rxlog", logToConsole: true );  
Report.AttachLogger(databaseLogger);
Because LogText is consistently working.

My second issue is that I notice the console log is recording more information than my custom logging class. Even when I set my logging level to Info, there are far less calls to LogText than there are lines of information in the console. How can I receive all those notifications so they can be logged to the database?

Thanks,
Robert

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Problem implementing IReportLogger

Post by Support Team » Fri Apr 18, 2014 9:21 am

Hello rostamizadeh,

LogData() is called whenever a Report.Screenshot() or Report.Snapshot() is used.
Regarding your second issue, can you give an example of a message that is logged to the console but not to the database?

Regards,
Robert
.
Image

rostamizadeh
Posts: 3
Joined: Thu Mar 27, 2014 10:44 pm

Re: Problem implementing IReportLogger

Post by rostamizadeh » Fri Apr 18, 2014 2:48 pm

Yes, it was my expectation that LogData() would be called anywhere a screenshot appears in a report, but that is not what I'm seeing happen.

Here's an example of what I see in my database after a run happens:
Screen Shot 2014-04-18 at 6.37.16 AM.png
Screen Shot 2014-04-18 at 6.37.16 AM.png (121.7 KiB) Viewed 1437 times
Note the one image that is stored in the database is from an explicit call I'm making to verify that I've implemented LogData():
var bmp = Imaging.CaptureDesktopImage( Host.Local );
Report.LogData( ReportLevel.Info, Report.DefaultCategory, bmp );

From the rxlog report that gets generated, you can see that there is much more information being logged...more than just at a module level. There are also three different screenshots that I would expect to see in my database, but when I set a breakpoint in LogData(), it never even gets hit.
Screen Shot 2014-04-18 at 6.44.31 AM.png
Screen Shot 2014-04-18 at 6.44.31 AM.png (86.88 KiB) Viewed 1437 times
The open console while the report is running also shows the detailed information that I'm seeing in the .rxlog.

Please let me know what additional information I can provide to assist in troubleshooting.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Problem implementing IReportLogger

Post by Support Team » Tue Apr 22, 2014 11:53 am

Hi,

I’m sorry if my clarification was not revealing.
LogData() is called whenever Report.Screenshot() or Report.Snapshot() is called, but not if just a validation step is used. That means that the image from the validation is visible in the report but LogData() isn’t called.
Regarding your issue with the data loss I would suggest that you send a small sample solution to [email protected] so that we can analyze your issue in more detail.

Regards,
Robert
.
Image

rostamizadeh
Posts: 3
Joined: Thu Mar 27, 2014 10:44 pm

Re: Problem implementing IReportLogger

Post by rostamizadeh » Tue Apr 22, 2014 7:08 pm

Thank you for your reply. So how can I capture the validation steps? Is there an event that I reference? I see there's an ActivityStack but it doesn't seem to be documented.

I'll work on putting together a sample solution for the data loss issue and will email that to you.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Problem implementing IReportLogger

Post by Support Team » Wed Apr 30, 2014 8:46 am

Hi rostamizadeh,

The log text from the validation step is handled by LogText() from the IReport Logger interface.

Unfortunately the image saving process from validation steps is handled internally and therefore cannot be influenced. I’m afraid that you will have to create your own method in order to save the pictures to your Postgres database.

The “Activity Stack” is, as well as all related methods, part of our internal API and therefore not documented. There are some discussions on our forum on how to modify/iterate over the “Activity Stack”. E.g.:
http://www.ranorex.com/forum/print-test ... tml#p14261

Please note that we do not recommend using undocumented API and do not guarantee for any side effects. Additionally, we preserve the right to change internal methods at any time.


Regards,
Robert
.
Image