GNOME Bugzilla – Bug 73409
logview should understand compressed log files
Last modified: 2004-12-22 21:47:04 UTC
Hallo, as many logfile rotation schemes use gzip to compress old log files, it would be nice if logview would be able to read compressed logfiles. Jochen
lets put this down for 2.0
definitely 2.x
logview CVS can now open gzipped and zipped logfiles. I'm not sure if the bz2 compression should be added... I'm closing this bug, if someone needs bz2 he should open another bug.
I'm re-opening this. Vincent: you should probably implement this using the gnome-vfs methods, rather than calling an exteral program and creating a tmp file. eg: file:/path/to/log#gzip:
Thanks, I was not aware of that, I am just learning gnome-vfs :P However it seems like getting the file info with gnome-vfs on a zipped file returns weird results (ie it returns the size of the zipped file and not the expanded file). Any hint ? :)
the gnome-vfs method for gzip (and i'd assume for zip), reads and writes to the file sequentially, so that you don't have to expand the entire thing into memory or onto disk at once, unless you choose too. as a consequence, you can really tell any information about the uncompressed file unless you actually uncompress it entirely yourself... so the method returns information about the gzip file, and then pulls out what it can about the uncompressed file inside but since the logs sit on disk as compressed files, that's probably a better file size to give to the user. anyways, since the two numbers will match
What I mean is that in order to read the (uncompressed) file I must know its size in order to g_malloc enough memory. I've tried a number of things, and even gnome_vfs_seek at the end of the zipped file makes the program crash. If I hard-code the file size into the program the reading routines work properly, but how do I access the uncompressed file size ???
I've just checked in the source of the gzip module in gnome-vfs and the seek, tell functions are now implemented for gzip. That explains why everything crashes when I try to use these functions. There's also a comment that gnome_vfs_get_file_info cannot retrieve the size of the uncompressed file. This is very unconvenient, but I'm looking into it.
I wouldn't worry about it. For one thing, a lot of the gnome-vfs modules can't get the file size, because the the method that they implement don't allow it. since you're just using the file size to allocate a buffer for chars, and then filling it up in one big gnome_vfs_read, why not use gnome_vfs_read_entire_file from gnome-vfs-utils?
Because gnome_vfs_read_entire_file does not work for gzip files because the gzip reading function is broken. See bug 157275 where I proposed a patch to fix this :-) I don't know what is best : include a patched version of gnome_vfs_read_entire_file in logview (I have this on my HD right now, and it works) or wait for the patched gnome-vfs to come out (this requirement could be quite hard for the people who just want to try gnome-utils). I think I'm gonna go with the first solution, and then use the gnome_vfs function when a new release of gnome-vfs is out. Any thoughts ?
wait for the patched gnome-utils, ie as soon as it hits cvs. I wouldn't worry too much about people who want to try it, since we're in a dev cycle.
logview CVS now opens zipped logfiles with the gzip method. You need gnome-vfs cvs (HEAD or gnome-2-8) to test it (otherwise, it'll crash). Thanks for all the help ! Can I close this bug, or does anyone has suggestions/criticism ?
just make sure the build scripts etc are updated to reflect the new requirement... which could probably be 2.8.2, or whatever the next stable gnome-vfs will be.
Good point. Thanks for pointing this out. gnome-vfs 2.8.3 is already out since october 28th, so I required gnome-vfs 2.8.4 in the configure.in. Closing the bug.