projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add config to display note at top, RT#84990
[freeside.git]
/
FS
/
FS
/
log.pm
diff --git
a/FS/FS/log.pm
b/FS/FS/log.pm
index
b8f51cd
..
875e1ac
100644
(file)
--- a/
FS/FS/log.pm
+++ b/
FS/FS/log.pm
@@
-4,9
+4,11
@@
use strict;
use base qw( FS::Record );
use FS::Record qw( qsearch qsearchs dbdef );
use FS::UID qw( dbh driver_name );
use base qw( FS::Record );
use FS::Record qw( qsearch qsearchs dbdef );
use FS::UID qw( dbh driver_name );
+use FS::Log;
use FS::log_context;
use FS::log_email;
use FS::upgrade_journal;
use FS::log_context;
use FS::log_email;
use FS::upgrade_journal;
+use Tie::IxHash;
=head1 NAME
=head1 NAME
@@
-46,8
+48,7
@@
this will be set to that agentnum.
=item tablenum - foreign key to that table.
=item tablenum - foreign key to that table.
-=item level - log level: 'debug', 'info', 'notice', 'warning', 'error',
-'critical', 'alert', 'emergency'.
+=item level - log level: 'debug', 'info', 'warning', 'error', 'critical',
=item message - contents of the log entry
=item message - contents of the log entry
@@
-82,6
+83,7
@@
sub insert {
my $self = shift;
my $error = $self->SUPER::insert;
return $error if $error;
my $self = shift;
my $error = $self->SUPER::insert;
return $error if $error;
+
my $contexts = {}; # for quick checks when sending emails
my $context_height = @_; # also for email check
foreach ( @_ ) { # ordered from least to most specific
my $contexts = {}; # for quick checks when sending emails
my $context_height = @_; # also for email check
foreach ( @_ ) { # ordered from least to most specific
@@
-93,6
+95,7
@@
sub insert {
return $error if $error;
$contexts->{$_} = $context_height--;
}
return $error if $error;
$contexts->{$_} = $context_height--;
}
+
foreach my $log_email (
qsearch('log_email',
{
foreach my $log_email (
qsearch('log_email',
{
@@
-113,11
+116,11
@@
sub insert {
next;
}
my $emailerror = $msg_template->send(
next;
}
my $emailerror = $msg_template->send(
- 'msgtype'
=> 'admin',
- 'to'
=> $log_email->to_addr,
+ 'msgtype' => 'admin',
+ 'to' => $log_email->to_addr,
'substitutions' => {
'substitutions' => {
- 'loglevel' => $FS::Log::LEVELS
[$self->level], # which has hopefully been loaded...
- 'logcontext' =>
$log_email->context, # use the one that triggered the email
+ 'loglevel' => $FS::Log::LEVELS
{$self->level} || 'unknown',
+ 'logcontext' =>
join(', ', keys( %$contexts )) || 'unknown',
'logmessage' => $self->message,
},
);
'logmessage' => $self->message,
},
);
@@
-390,24
+393,19
@@
sub _upgrade_data {
return if FS::upgrade_journal->is_done('log__remap_levels');
tie my %levelmap, 'Tie::IxHash',
return if FS::upgrade_journal->is_done('log__remap_levels');
tie my %levelmap, 'Tie::IxHash',
-# 0 => 0, #debug
-# 1 => 1, #info
2 => 1, #notice -> info
2 => 1, #notice -> info
- 3 => 2, #warning
- 4 => 3, #error
- 5 => 4, #critical
- 6 => 4, #alert -> critical
- 7 => 4, #emergency -> critical
+ 6 => 5, #alert -> critical
+ 7 => 5, #emergency -> critical
;
# this method should never autocommit
# should have been set in upgrade, but just in case...
local $FS::UID::AutoCommit = 0;
;
# this method should never autocommit
# should have been set in upgrade, but just in case...
local $FS::UID::AutoCommit = 0;
- # FS::log has no replace method
- # in practice, only debug/info/warning/error were used,
- # so this should only hit warning/error
+ # in practice, only debug/info/warning/error appear to have been used,
+ # so this probably won't do anything, but just in case
foreach my $old (keys %levelmap) {
foreach my $old (keys %levelmap) {
+ # FS::log has no replace method
my $sql = 'UPDATE log SET level=' . dbh->quote($levelmap{$old}) . ' WHERE level=' . dbh->quote($old);
warn $sql unless $opts{'quiet'};
my $sth = dbh->prepare($sql) or die dbh->errstr;
my $sql = 'UPDATE log SET level=' . dbh->quote($levelmap{$old}) . ' WHERE level=' . dbh->quote($old);
warn $sql unless $opts{'quiet'};
my $sth = dbh->prepare($sql) or die dbh->errstr;
@@
-416,7
+414,9
@@
sub _upgrade_data {
}
foreach my $log_email (
}
foreach my $log_email (
- qsearch('log_email',{ 'min_level' => { 'op' => '>=', 'value' => '2' } })
+ qsearch('log_email',{ 'min_level' => 2 }),
+ qsearch('log_email',{ 'min_level' => 6 }),
+ qsearch('log_email',{ 'min_level' => 7 }),
) {
$log_email->min_level($levelmap{$log_email->min_level});
my $error = $log_email->replace;
) {
$log_email->min_level($levelmap{$log_email->min_level});
my $error = $log_email->replace;