| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Solr; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
33166
|
use 5.006; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
44
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
36
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
29
|
|
|
6
|
1
|
|
|
1
|
|
607
|
use Solr::Schema; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Solr::HTTPUpdateHandler |
|
8
|
|
|
|
|
|
|
qw(add _fixXmlEndTag delete_by_id delete_by_query commit optimize _postRequest add_by_file _logAddDeletes _logPost post_file); |
|
9
|
|
|
|
|
|
|
use POSIX qw(strftime); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Log::Log4perl; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
require Exporter; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
|
18
|
|
|
|
|
|
|
'all' => [ |
|
19
|
|
|
|
|
|
|
qw( |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
) |
|
22
|
|
|
|
|
|
|
] |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Preloaded methods go here. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $class = shift; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my (%params) = @_; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $self = \%params; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
bless( $self, $class ); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$self->_init; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
return $self; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _init { |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $self = shift; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# date string for default log file naming. |
|
55
|
|
|
|
|
|
|
my $date = strftime "%Y%m%d", localtime; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Logging (optional params that can be modified from default in initialization). |
|
58
|
|
|
|
|
|
|
$self->{log_dir} ||= "./"; |
|
59
|
|
|
|
|
|
|
$self->{info_log} ||= "info.$date.log"; |
|
60
|
|
|
|
|
|
|
$self->{error_log} ||= "error.$date.log"; |
|
61
|
|
|
|
|
|
|
$self->{debug_log} ||= "debug.$date.log"; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my %log4_init; |
|
64
|
|
|
|
|
|
|
# unless $self->{logging_on explitly turned off by setting to 0, turn on default logging. |
|
65
|
|
|
|
|
|
|
unless ($self->{disable_logging}) { |
|
66
|
|
|
|
|
|
|
%log4_init = ( |
|
67
|
|
|
|
|
|
|
"log4perl.logger"=> "INFO, AppWarn, AppError", |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
"log4perl.filter.MatchError" => "Log::Log4perl::Filter::LevelMatch", |
|
70
|
|
|
|
|
|
|
"log4perl.filter.MatchError.LevelToMatch" => "ERROR", |
|
71
|
|
|
|
|
|
|
"log4perl.filter.MatchError.AcceptOnMatch" => "true", |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
"log4perl.filter.MatchInfo" => "Log::Log4perl::Filter::LevelMatch", |
|
74
|
|
|
|
|
|
|
"log4perl.filter.MatchInfo.LevelToMatch" => "INFO", |
|
75
|
|
|
|
|
|
|
"log4perl.filter.MatchInfo.AcceptOnMatch" => "true", |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
"log4perl.appender.AppError" => "Log::Log4perl::Appender::File", |
|
78
|
|
|
|
|
|
|
"log4perl.appender.AppError.filename" => "$self->{log_dir}/$self->{error_log}", |
|
79
|
|
|
|
|
|
|
"log4perl.appender.AppError.layout" => "Log::Log4perl::Layout::PatternLayout", |
|
80
|
|
|
|
|
|
|
"log4perl.appender.AppError.layout.ConversionPattern" => '%d %p [%c] (%F line %L) %m%n', |
|
81
|
|
|
|
|
|
|
"log4perl.appender.AppError.Filter" => "MatchError", |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
"log4perl.appender.AppWarn" => "Log::Log4perl::Appender::File", |
|
84
|
|
|
|
|
|
|
"log4perl.appender.AppWarn.filename" => "$self->{log_dir}/$self->{info_log}", |
|
85
|
|
|
|
|
|
|
"log4perl.appender.AppWarn.layout" => "Log::Log4perl::Layout::PatternLayout", |
|
86
|
|
|
|
|
|
|
"log4perl.appender.AppWarn.layout.ConversionPattern" => '%d %p %m%n', |
|
87
|
|
|
|
|
|
|
"log4perl.appender.AppWarn.Filter" => "MatchInfo", |
|
88
|
|
|
|
|
|
|
); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
#otherwise send fatal errors to the screen and ignore other messages. |
|
91
|
|
|
|
|
|
|
else { |
|
92
|
|
|
|
|
|
|
%log4_init = ( |
|
93
|
|
|
|
|
|
|
"log4perl.logger"=> "FATAL,Screen", |
|
94
|
|
|
|
|
|
|
"log4perl.appender.Screen" => "Log::Log4perl::Appender::Screen", |
|
95
|
|
|
|
|
|
|
"log4perl.appender.Screen.layout" => "SimpleLayout", |
|
96
|
|
|
|
|
|
|
); |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# blessed reference to log. Log4perl handles passing this into subclasses |
|
102
|
|
|
|
|
|
|
$self->{log} = Log::Log4perl->init( \%log4_init ); |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
$self->{schema} = Solr::Schema->new( |
|
105
|
|
|
|
|
|
|
schema => $self->{schema}, |
|
106
|
|
|
|
|
|
|
url => $self->{url}, |
|
107
|
|
|
|
|
|
|
port => $self->{port}, |
|
108
|
|
|
|
|
|
|
); |
|
109
|
|
|
|
|
|
|
# may want to put a conditional around this in the event this class is also used to interface |
|
110
|
|
|
|
|
|
|
# future Search and resultHandler modules Yousef Ourabi is working on. |
|
111
|
|
|
|
|
|
|
$self->{HTTPUpdateHandler} = Solr::HTTPUpdateHandler->new( |
|
112
|
|
|
|
|
|
|
schema => $self->{schema}, |
|
113
|
|
|
|
|
|
|
); |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
return $self; |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |
|
120
|
|
|
|
|
|
|
__END__ |