Revert "Getting rid of tabs."

This reverts commit cc1c8fd5bc.
Failed.
This commit is contained in:
Elijah Perrault committed 2011-02-20 20:47:09 -07:00
1 parent cc1c8fd5bc
commit 92c9a64793
20 files changed
+1277 -1279

No files matched your search

+55 -55
View File
@@ -18,11 +18,11 @@ our @EXPORT_OK = qw(println dbug alog slog);
# Print with the system newline appended.
sub println
{
ssssmy ($out) = @_;
my ($out) = @_;
ssssif (!defined $out) {
ssss print $RS;
ssss}
if (!defined $out) {
print $RS;
}
else {
print $out.$RS;
}
@@ -33,79 +33,79 @@ ssss}
# Print only if in debug mode.
sub dbug
{
ssssmy ($out) = @_;
my ($out) = @_;
ssssif ($Auto::DEBUG) {
ssss # We're in debug mode; print it out.
ssss say $out;
ssss}
if ($Auto::DEBUG) {
# We're in debug mode; print it out.
say $out;
}
ssssreturn 1;
return 1;
}
# Log to file.
sub alog
{
ssssmy ($lmsg) = @_;
my ($lmsg) = @_;
ssss# Expire old logs first.
ssssexpire_logs();
# Expire old logs first.
expire_logs();
ssss# Get date and time in the desired format.
ssssmy $date = POSIX::strftime('%Y%m%d', localtime);
ssssmy $time = POSIX::strftime('%Y-%m-%d %I:%M:%S %p', localtime);
# Get date and time in the desired format.
my $date = POSIX::strftime('%Y%m%d', localtime);
my $time = POSIX::strftime('%Y-%m-%d %I:%M:%S %p', localtime);
ssss# Create var/ if it doesn't exist.
ssssif (!-d "$Auto::Bin/../var") {
ssss mkdir "$Auto::Bin/../var", 0600; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
ssss}
ssss# Create var/DATE.log if it doesn't exist.
ssssif (!-e "$Auto::Bin/../var/$date.log") {
ssss system "touch $Auto::Bin/../var/$date.log";
ssss}
# Create var/ if it doesn't exist.
if (!-d "$Auto::Bin/../var") {
mkdir "$Auto::Bin/../var", 0600; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
}
# Create var/DATE.log if it doesn't exist.
if (!-e "$Auto::Bin/../var/$date.log") {
system "touch $Auto::Bin/../var/$date.log";
}
ssss# Open the logfile, print the log message to it and close it.
ssssopen my $FLOG, '>>', "$Auto::Bin/../var/$date.log" or return;
ssssprint {$FLOG} "[$time] $lmsg\n" or return;
ssssclose $FLOG or return;
# Open the logfile, print the log message to it and close it.
open my $FLOG, '>>', "$Auto::Bin/../var/$date.log" or return;
print {$FLOG} "[$time] $lmsg\n" or return;
close $FLOG or return;
ssssreturn 1;
return 1;
}
# Expire old logs.
sub expire_logs
{
ssss# Get configuration value.
ssssmy $celog = (conf_get('expire_logs'))[0][0] or return;
# Get configuration value.
my $celog = (conf_get('expire_logs'))[0][0] or return;
ssss# Check for invalid values.
ssssif ($celog =~ m/[^0-9]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting)
ssss # Must be numbers only.
ssss return;
ssss}
sssselsif (!$celog) {
ssss # No expire.
ssss return;
ssss}
# Check for invalid values.
if ($celog =~ m/[^0-9]/sm) { ## no critic qw(RegularExpressions::RequireExtendedFormatting)
# Must be numbers only.
return;
}
elsif (!$celog) {
# No expire.
return;
}
ssss# Iterate through each logfile.
ssssforeach my $file (glob "$Auto::Bin/../var/*") {
ssss my (undef, $file) = split 'bin/../var/', $file; ## no critic qw(BuiltinFunctions::ProhibitStringySplit)
# Iterate through each logfile.
foreach my $file (glob "$Auto::Bin/../var/*") {
my (undef, $file) = split 'bin/../var/', $file; ## no critic qw(BuiltinFunctions::ProhibitStringySplit)
ssss # Convert filename to UNIX time.
ssss my $yyyy = substr $file, 0, 4; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
ssss my $mm = substr $file, 4, 2; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
ssss $mm = $mm - 1;
ssss my $dd = substr $file, 6, 2; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
ssss my $epoch = timelocal(0, 0, 0, $dd, $mm, $yyyy);
# Convert filename to UNIX time.
my $yyyy = substr $file, 0, 4; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
my $mm = substr $file, 4, 2; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
$mm = $mm - 1;
my $dd = substr $file, 6, 2; ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
my $epoch = timelocal(0, 0, 0, $dd, $mm, $yyyy);
ssss # If it's older than <config_value> days, delete it.
ssss if (time - $epoch > 86_400 * $celog) { ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
ssss unlink "$Auto::Bin/../var/$file";
ssss }
ssss}
# If it's older than <config_value> days, delete it.
if (time - $epoch > 86_400 * $celog) { ## no critic qw(ValuesAndExpressions::ProhibitMagicNumbers)
unlink "$Auto::Bin/../var/$file";
}
}
ssssreturn 1;
return 1;
}
# Subroutine for logging to an IRC logchan.