1 #----------------------------------------------------------------------
2 # Monkeysphere Validation Agent, Perl version
3 # Marginal User Interface for reasonable prompting
4 # Copyright © 2010 Daniel Kahn Gillmor <dkg@fifthhorseman.net>,
5 # Matthew James Goins <mjgoins@openflows.com>,
6 # Jameson Graef Rollins <jrollins@finestructure.net>,
7 # Elliot Winard <enw@caveteen.com>
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #----------------------------------------------------------------------
24 { package Crypt::Monkeysphere::MSVA::Logger;
29 # Net::Server log_level goes from 0 to 4
30 # this is scaled to match.
48 if ($loglevels{lc($msglevel)} <= $self->{loglevel}) {
56 return $self->{loglevel};
61 my $logval = $loglevels{lc($loglevel)};
63 if (defined($logval)) {
64 $self->{loglevel} = $logval;
66 $self->log('error', "Invalid log level: '%s' (log level not changed)\n", $loglevel);
71 my $increment = shift;
74 if (!defined $increment);
75 $self->{loglevel} += $increment;
78 # let the user test to see if we're noisier than this level
84 return ($loglevels{lc($qlevel)} <= $self->{loglevel});
91 my $self = {loglevel => $loglevels{lc($loglevel)}};
92 $self->{loglevel} = $loglevels{error}
93 if (!defined $self->{loglevel});
95 bless ($self, $class);