diff options
author | Russ Allbery <rra@stanford.edu> | 2007-10-10 20:15:03 +0000 |
---|---|---|
committer | Russ Allbery <rra@stanford.edu> | 2007-10-10 20:15:03 +0000 |
commit | 9e6b38452a221eca3c0ac775ba08ab4696716b71 (patch) | |
tree | 5cc23dd4e4311de44e09b6bcc8eb2b846f376b10 /perl | |
parent | e4d11b740c11948068731f439c108dee479e63f0 (diff) |
Redo history tracking for attributes. Currently, all of our attributes
take multiple values, so log them like flags. Hopefully this will
continue to work; if not, we'll have to revisit it later.
Improve logging for unsetting of attributes.
Diffstat (limited to 'perl')
-rw-r--r-- | perl/Wallet/Object/Base.pm | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/perl/Wallet/Object/Base.pm b/perl/Wallet/Object/Base.pm index 7320dd6..ada211c 100644 --- a/perl/Wallet/Object/Base.pm +++ b/perl/Wallet/Object/Base.pm @@ -460,24 +460,30 @@ sub history { while (@data = $sth->fetchrow_array) { my $time = strftime ('%Y-%m-%d %H:%M:%S', localtime $data[7]); $output .= "$time "; + my ($old, $new) = @data[3..4]; if ($data[0] eq 'set' and $data[1] eq 'flags') { if (defined ($data[4])) { $output .= "set flag $data[4]"; } elsif (defined ($data[3])) { $output .= "clear flag $data[3]"; } + } elsif ($data[0] eq 'set' and $data[1] eq 'type_data') { + my $attr = $data[2]; + if (defined ($old) and defined ($new)) { + $output .= "set attribute $attr to $new (was $old)"; + } elsif (defined ($old)) { + $output .= "remove $old from attribute $attr"; + } elsif (defined ($new)) { + $output .= "add $new to attribute $attr"; + } } elsif ($data[0] eq 'set') { my $field = $data[1]; - if ($field eq 'type_data') { - $field = $data[2]; - } - my ($old, $new) = @data[3..4]; if (defined ($old) and defined ($new)) { $output .= "set $field to $new (was $old)"; } elsif (defined ($new)) { $output .= "set $field to $new"; } elsif (defined ($old)) { - $output .= "unset $field"; + $output .= "unset $field (was $old)"; } } else { $output .= $data[0]; |