Bug 824 - idlelog..log corrupted on Windows
Status:
RESOLVED FIXED
Component:
Core :: Win32
Version:
1.9.0
Hardware:
PC Windows Vista
Importance:
P2 normal
Target Milestone:
---
Assignee:
Ray Satiro
URL:
Depends on:
Blocks:
Reported:
Mar 16 2009 05:03:51 UTC
by:
Andrej Pavlovic
Modified:
Mar 29 2009 12:47:41 UTC
CC List:
Ray Satiro
Rob Caelers
IdWhoWhenSizeType
183Corrupted log sample
Andrej PavlovicMar 26 2009 14:04:55 UTC225453application/octet-stream
WhoWhenWhatRemovedAdded
Andrej PavlovicMar 17 2009 02:52:02 UTCpriorityP5P2
Ray SatiroMar 26 2009 05:28:57 UTCassigned_toRaymond PennersRay Satiro
severitycriticalnormal
ccRay Satiro
statusNEWASSIGNED
Rob CaelersMar 29 2009 12:47:41 UTCstatusASSIGNEDRESOLVED
ccRob Caelers
resolutionFIXED
Description
Andrej Pavlovic  Mar 16 2009 05:03:51 UTC
I tried parsing idlelog..log file myself, but found what seemed extra bytes inserted randomly throughout the file. To get to the root of the cause I compiled a part of the code, PacketBuffer and IdleLogManager, and reproduced the issue consistently.

The problem is that the binary stream is being saved to a file that was not opened in binary mode. As a result, Windows inserts a line feed \r before every \n, thus corrupting the logfile.

So basically this piece of code:
ofstream file(ss.str().c_str());
needs to be replaced with something like this:
ofstream file(ss.str().c_str(), ios::binary);

I am not sure if this is the best way to solve this and all the places where this needs to be fixed, but this is a major issue for the Windows platform.

BTW: Thanks a lot for this great app!
Comment 1
Ray Satiro  Mar 26 2009 05:28:57 UTC
Thanks for your report. Is your idlelog..log big? Can you share with us your intentions in parsing the log?
Comment 2
Andrej Pavlovic  Mar 26 2009 14:04:55 UTC
Created attachment 183
Corrupted log sample
Comment 3
Andrej Pavlovic  Mar 26 2009 14:11:58 UTC
Well I am not sure if the log is pretty big, but I think it has about four months worth of data. I guess that's about the maximum it can have.

The idea behind parsing the log is I wanted to see if I could generate some interesting reports/graphs using the raw data. The historystats file doesn't have data by the hour for example which may be interesting to compare historically. Anyway, I was using PHP to parse the file and if all went well make it into a web based script where I could upload the logs and get graphs/reports in return.

Thanks for looking into this.
Comment 4
Rob Caelers  Mar 29 2009 12:47:41 UTC
I added the "ios::binary" and increased the version number of the idlelog. The next release of workrave will first remove old idlelogs.

Thanks!