projects
/
dweather.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add 2 day forecast, blue -(ve) temperature
[dweather.git]
/
SMGLog.pm
diff --git
a/SMGLog.pm
b/SMGLog.pm
index d52d9b3f57ec65e244a64d66cb15a4891fe585fe..9adf77a75a977d4d7cf01badb9e79aaa29f6fd23 100644
(file)
--- a/
SMGLog.pm
+++ b/
SMGLog.pm
@@
-53,6
+53,7
@@
sub new
my $dir = "$path/$prefix";
$ref->{prefix} = $dir;
$ref->{suffix} = $suffix || 'log';
my $dir = "$path/$prefix";
$ref->{prefix} = $dir;
$ref->{suffix} = $suffix || 'log';
+ $ref->{dayno} = int (time / 86400);
# make sure the directory exists
mkpath($dir, 0, 0777) unless -d $dir;
# make sure the directory exists
mkpath($dir, 0, 0777) unless -d $dir;
@@
-124,11
+125,11
@@
sub opennext
sub write
{
my ($self, $dayno, $line) = @_;
sub write
{
my ($self, $dayno, $line) = @_;
- if (
!$self->{fh} || $self->{mode} ne "r" || $dayno != $self->{dayno}
) {
+ if (
(!$self->{fh} || $dayno != $self->{dayno}) && $self->{mode} ne "r"
) {
$self->open($dayno, "a+") or confess "can't open $self->{fn} $!";
$self->open($dayno, "a+") or confess "can't open $self->{fn} $!";
- }
+ }
- return $self->{fh}
->print("$line\n")
;
+ return $self->{fh}
? $self->{fh}->print("$line\n") : undef
;
}
# read a line from an opened file
}
# read a line from an opened file