1
# This program is copyright 2013 Percona Ireland Ltd.
2
# Feedback and improvements are welcome.
4
# THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
5
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
6
# MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
8
# This program is free software; you can redistribute it and/or modify it under
9
# the terms of the GNU General Public License as published by the Free Software
10
# Foundation, version 2; OR the Perl Artistic License. On UNIX and similar
11
# systems, you can issue `man perlgpl' or `man perlartistic' to read these
14
# You should have received a copy of the GNU General Public License along with
15
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16
# Place, Suite 330, Boston, MA 02111-1307 USA.
17
# ###########################################################################
18
# Percona::Agent::Logger package
19
# ###########################################################################
20
package Percona::Test::Mock::AgentLogger;
23
use warnings FATAL => 'all';
24
use English qw(-no_match_vars);
26
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
29
my ($class, %args) = @_;
33
exit_status => $args{exit_status},
35
online_logging => $args{online_logging},
42
return bless $self, $class;
48
$self->{service} = $_service if $_service;
49
return $self->{service};
55
$self->{data_ts} = $_data_ts if $_data_ts;
56
return $self->{data_ts};
62
$self->{quiet} = $_quiet if $_quiet;
63
return $self->{quiet};
66
sub start_online_logging {
67
my ($self, %args) = @_;
68
$self->_log('-', 'Called start_online_logging()');
74
die "No log level name given" unless $name;
75
my $number = $name eq 'DEBUG' ? 1
77
: $name eq 'WARNING' ? 3
78
: $name eq 'ERROR' ? 4
79
: $name eq 'FATAL' ? 5
80
: die "Invalid log level name: $name";
85
die "No log level name given" unless $number;
86
my $name = $number == 1 ? 'DEBUG'
87
: $number == 2 ? 'INFO'
88
: $number == 3 ? 'WARNING'
89
: $number == 4 ? 'ERROR'
90
: $number == 5 ? 'FATAL'
91
: die "Invalid log level number: $number";
96
return $self->_log('DEBUG', @_);
101
return $self->_log('INFO', @_);
106
return $self->_log('WARNING', @_);
111
return $self->_log('ERROR', @_);
116
$self->_log('FATAL', @_);
121
my ($self, $level, $msg) = @_;
122
push @{$self->{log}}, "$level $msg";
127
# ###########################################################################
128
# End Percona::Test::Mock::AgentLogger package
129
# ###########################################################################