You are not logged in.
Pages: 1
I've written a script to clean up the pacman log file. (It was 32 MB on my system, mostly because Sage was built in the post_install function and thus spammed the log file.)
I've posted it on my site along with an explanation of what it does. (I've added syntax highlighting to my toolchain and wanted an excuse to use it. )
Last edited by Xyne (2010-05-06 12:33:09)
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
i suggest to remove someting logs about "abc" package if there are both "installed abc" and "removed abc".
Offline
Do you mean that it should remove e.g. "[YYYY-mm-dd HH:MM] removed abc (1.2.3)" and all entries related to "abc" before it?
I suppose I could add an option to do that.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Haven't tried the script (mainly because i don't want to mess with my logfile (and it's just 700k)) but i saw this on the description part:
The second argument is the path to the log file (default: /etc/pacman.log).
Syntax highlighting ftw though
Ogion
Last edited by Ogion (2010-05-06 14:30:09)
(my-dotfiles)
"People willing to trade their freedom for temporary security deserve neither and will lose both." - Benjamin Franklin
"Enlightenment is man's leaving his self-caused immaturity." - Immanuel Kant
Offline
Personal style point, but I find
my $months = shift || 6;
to be much more readable than
my $months = @ARGV ? shift @ARGV : 6;
[git] | [AURpkgs] | [arch-games]
Offline
@Ogion
If it's only 700k then there's obviously no need for this, but as already mentioned it doesn't change the log file.
and yeah, markdown + pandoc + source-highlight + some scripts = win (at least I'm happy with it)
@Daenyth
The example that you give will fail with all arguments that do not evaluate to "true" in a boolean context, which would thus prevent a user from using 0, which would be a valid argument.
I will admit that I hadn't even considered that form and I agree that it is nice and succinct, but the difference in readability is negligible for a Perl coder and debatable for others. I expect that implicit arguments would be a source of confusion for some, but so might the ternary operator, so meh.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Ah, I hadn't considered that an argument of 0 would cause that to fail. Good catch
Aha, after looking into it further, what you want is // instead of ||. Short-circuit operator that's pretty much made for that exact use.
daenyth@Bragi ~ $ perl -E 'say shift || "fail"' 0
fail
daenyth@Bragi ~ $ perl -E 'say shift // "fail"' 0
0
daenyth@Bragi ~ $ perl -E 'say shift // "fail"'
fail
And yeah, ternary is ugly. As for implicit args, it's not required: "shift @ARGV // 6". Embrace the perlisms!
Last edited by Daenyth (2010-05-06 16:12:35)
[git] | [AURpkgs] | [arch-games]
Offline
I'd never seen the "defined-or" operator before. I also found the "yada yada" operator while looking it up on perlop.
I've updated the script... now maybe we can focus on what it does instead of how it looks.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Hehe I wrote something similar to this one for myself a few days ago. It cleans the pacman.log of spam as "Synchronizing package databases..." and "Starting full system upgrade..." lines.
If anyone wants it, here it is...(author of the thread, if you find my post appropriate, please contact me or write here, and I will remove this code. )
sudo pacman -Syu &&
sudo sed -i '/starting full system upgrade/ d' /var/log/pacman.log &&
sudo sed -i '/synchronizing package lists/ d' /var/log/pacman.log &&
echo "==> log file cleared of spam messages" &&
echo "==> exit" &&
date +'%A, %d.%m.%y., %k:%M' > /home/<YOUR_USER_HERE>/.scripts/synched # or whatever you like
The last line is to keep track of when pacman was last synched.
Cheers.
Offline
Pages: 1