Re: parsing idlelog..log in Perl (was: historystats file format documentation)
Zdeněk Kedaj <[email protected]>
| Newsgroups | gmane.comp.misc.workrave.user |
|---|---|
| Message-ID | <[email protected]> |
Thanks for more info on this Joe! I think I will stick to the historystat file because it contains keyboard and mouse activity records I am interested in. Although it would be nice to have activity log in finer granularity I can make some simplifications :) Zdenek 2010/4/26 Joe Wells <[email protected]> > Zdeněk Kedaj <[email protected]> writes: > > > 2010/4/25 Joe Wells <[email protected]> > > > > Sorry for being confusing. The information you want is in the > > “idlelog..log” file. If you look for earlier postings on this > mailing > > list, you can find programs that process this data. > > > > Hm, but this file is in binary format which is quite hard to parse. Does > it > > contain any more data than the historystats file? > > It contains the start and stop time of each idle interval. > > I remember posting Perl code that would parse it. The format is not > complicated. Each record is fixed length, and each field is a fixed > size at a fixed offset within each record. Here is the relevant Perl > code that unpacks the entire file: > > # C: unsigned 8-bit integer (“c” is for “char”) > # n: unsigned 16-bit integer in big-endian order (“n” is for “network” > order) > # N: unsigned 32-bit integer in big-endian order > > # 17 bytes total > my $IdleLogRecordFormat = ' > n # size (should always be 15, encoded in bytes as 0 followed by 15) > C # format version (should always be 2, encoded as the byte 2) > N # begin time > N # end idle time > N # end time > n # active time > '; > > ... > > my $contents = get_file_contents ($file); # grab entire file as a single > string > my @all_record_fields = unpack ("($IdleLogRecordFormat)*", $contents); > > After this code runs, each record takes 6 consecutive slots in > @all_record_fields. > > I hope this helps. > > -- > Joe > > > -- > Heriot-Watt University is a Scottish charity > registered under charity number SC000278. > > ------------------------------------------------------------------------------ _______________________________________________ Workrave-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/workrave-user