| 1 | package Solr; | ||||||||||||
| 2 | |||||||||||||
| 3 | 1 | ▶ | use 5.006; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 1 | ▶ | use Solr::Schema; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | use Solr::HTTPUpdateHandler | ||||||||||||
| 8 | 1 | ▶ | qw(add _fixXmlEndTag delete_by_id delete_by_query commit optimize _postRequest add_by_file _logAddDeletes _logPost post_file); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 1 | ▶ | use POSIX qw(strftime); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 1 | ▶ | use Log::Log4perl; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | |||||||||||||
| 13 | 1 | require Exporter; | |||||||||||
| 14 | |||||||||||||
| 15 | 1 | our @ISA = qw(Exporter); | |||||||||||
| 16 | |||||||||||||
| 17 | 1 | our %EXPORT_TAGS = ( | |||||||||||
| 18 | 'all' => [ | ||||||||||||
| 19 | qw( | ||||||||||||
| 20 | |||||||||||||
| 21 | ) | ||||||||||||
| 22 | ] | ||||||||||||
| 23 | ); | ||||||||||||
| 24 | |||||||||||||
| 25 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||
| 26 | |||||||||||||
| 27 | 1 | our @EXPORT = qw( | |||||||||||
| 28 | |||||||||||||
| 29 | ); | ||||||||||||
| 30 | |||||||||||||
| 31 | 1 | our $VERSION = '0.03'; | |||||||||||
| 32 | |||||||||||||
| 33 | # Preloaded methods go here. | ||||||||||||
| 34 | |||||||||||||
| 35 | 0 | ▶ | sub new { | ||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 36 | |||||||||||||
| 37 | 0 | my $class = shift; | |||||||||||
| 38 | |||||||||||||
| 39 | 0 | my (%params) = @_; | |||||||||||
| 40 | |||||||||||||
| 41 | 0 | my $self = \%params; | |||||||||||
| 42 | |||||||||||||
| 43 | 0 | bless( $self, $class ); | |||||||||||
| 44 | |||||||||||||
| 45 | 0 | $self->_init; | |||||||||||
| 46 | |||||||||||||
| 47 | 0 | return $self; | |||||||||||
| 48 | } | ||||||||||||
| 49 | |||||||||||||
| 50 | 0 | ▶ | sub _init { | ||||||||||
|
Subroutine
_init: not called CC=6 SCAR=37.4
| |||||||||||||
| 51 | |||||||||||||
| 52 | 0 | my $self = shift; | |||||||||||
| 53 | |||||||||||||
| 54 | # date string for default log file naming. | ||||||||||||
| 55 | 0 | my $date = strftime "%Y%m%d", localtime; | |||||||||||
| 56 | |||||||||||||
| 57 | # Logging (optional params that can be modified from default in initialization). | ||||||||||||
| 58 | 0 | ▶ | $self->{log_dir} ||= "./"; | ||||||||||
|
Condition0%0/2
$self->{"log_dir"} ||= "./"
MC/DC0%0/1
$self->{"log_dir"} ||= "./"
$self->{"log_dir"}
Truth table0%0/2
A
A= $self->{"log_dir"}
| |||||||||||||
| 59 | 0 | ▶ | $self->{info_log} ||= "info.$date.log"; | ||||||||||
|
Condition0%0/2
$self->{"info_log"} ||= "info.$date.log"
MC/DC0%0/1
$self->{"info_log"} ||= "info.$date.log"
$self->{"info_log"}
Truth table0%0/2
A
A= $self->{"info_log"}
| |||||||||||||
| 60 | 0 | ▶ | $self->{error_log} ||= "error.$date.log"; | ||||||||||
|
Condition0%0/2
$self->{"error_log"} ||= "error.$date.log"
MC/DC0%0/1
$self->{"error_log"} ||= "error.$date.log"
$self->{"error_log"}
Truth table0%0/2
A
A= $self->{"error_log"}
| |||||||||||||
| 61 | 0 | ▶ | $self->{debug_log} ||= "debug.$date.log"; | ||||||||||
|
Condition0%0/2
$self->{"debug_log"} ||= "debug.$date.log"
MC/DC0%0/1
$self->{"debug_log"} ||= "debug.$date.log"
$self->{"debug_log"}
Truth table0%0/2
A
A= $self->{"debug_log"}
| |||||||||||||
| 62 | |||||||||||||
| 63 | 0 | my %log4_init; | |||||||||||
| 64 | # unless $self->{logging_on explitly turned off by setting to 0, turn on default logging. | ||||||||||||
| 65 | 0 | ▶ | unless ($self->{disable_logging}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 66 | 0 | %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 | 0 | %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 | 0 | $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 | 0 | ); | |||||||||||
| 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 | 0 | ); | |||||||||||
| 114 | |||||||||||||
| 115 | 0 | return $self; | |||||||||||
| 116 | |||||||||||||
| 117 | } | ||||||||||||
| 118 | |||||||||||||
| 119 | 1 | 1; | |||||||||||
| 120 | __END__ | ||||||||||||