line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Binance::API::Logger; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# MIT License |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Copyright (c) 2017 Lari Taskula |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy |
8
|
|
|
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal |
9
|
|
|
|
|
|
|
# in the Software without restriction, including without limitation the rights |
10
|
|
|
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
11
|
|
|
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is |
12
|
|
|
|
|
|
|
# furnished to do so, subject to the following conditions: |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# The above copyright notice and this permission notice shall be included in all |
15
|
|
|
|
|
|
|
# copies or substantial portions of the Software. |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
18
|
|
|
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
19
|
|
|
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
20
|
|
|
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
21
|
|
|
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
22
|
|
|
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
23
|
|
|
|
|
|
|
# SOFTWARE. |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
3
|
|
72428
|
use strict; |
|
3
|
|
|
|
|
13
|
|
|
3
|
|
|
|
|
72
|
|
26
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
56
|
|
27
|
|
|
|
|
|
|
|
28
|
3
|
|
|
3
|
|
12
|
use Carp; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
150
|
|
29
|
|
|
|
|
|
|
|
30
|
3
|
|
|
3
|
|
1073
|
use Binance::Constants qw( :all ); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
902
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 NAME |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Binance::API::Logger -- Logger for L |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 DESCRIPTION |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Provides a wrapper for your desired logger. Carps log calls higher than "debug" |
39
|
|
|
|
|
|
|
level |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 SYNOPSIS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
use Binance::API; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $logger = Binance::API::Logger->new($log4perl); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$logger->warn("This is a warning"); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 METHODS |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 new |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $logger = Binance::API::Logger->new($log4perl); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Instantiates a new C object. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
B |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=over |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item A logger object that implements (at least) debug, warn, |
64
|
|
|
|
|
|
|
error, fatal level logging. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
[OPTIONAL] |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=back |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
B |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
A C object. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub new { |
77
|
5
|
|
|
5
|
1
|
4885
|
my $class = shift; |
78
|
|
|
|
|
|
|
|
79
|
5
|
|
|
|
|
16
|
my $self = { |
80
|
|
|
|
|
|
|
logger => undef, |
81
|
|
|
|
|
|
|
}; |
82
|
|
|
|
|
|
|
|
83
|
5
|
100
|
|
|
|
20
|
$self->{logger} = shift if @_; |
84
|
|
|
|
|
|
|
|
85
|
5
|
|
|
|
|
19
|
bless $self, $class; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub AUTOLOAD { |
89
|
56
|
|
|
56
|
|
3483
|
my $self = shift; |
90
|
|
|
|
|
|
|
|
91
|
56
|
|
|
|
|
85
|
my $level = our $AUTOLOAD; |
92
|
56
|
|
|
|
|
267
|
$level =~ s/.*://; |
93
|
|
|
|
|
|
|
|
94
|
56
|
100
|
|
|
|
292
|
return if $level eq 'DESTROY'; |
95
|
|
|
|
|
|
|
|
96
|
51
|
|
50
|
|
|
126
|
my $message = shift || ""; |
97
|
|
|
|
|
|
|
|
98
|
51
|
|
|
|
|
161
|
my $sub = (caller(1))[3]; |
99
|
51
|
|
|
|
|
1023
|
my $full_message = "[$sub] ". $message; |
100
|
|
|
|
|
|
|
|
101
|
51
|
100
|
66
|
|
|
215
|
if ($level eq 'debug' || $level eq 'trace') { |
102
|
14
|
|
|
|
|
19
|
carp $full_message if DEBUG; |
103
|
|
|
|
|
|
|
} else { |
104
|
37
|
|
|
|
|
425
|
carp $full_message; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
51
|
50
|
33
|
|
|
8707
|
if ($self->{logger} && $self->{logger}->can($level)) { |
108
|
0
|
|
|
|
|
|
$self->{logger}->$level($full_message); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |