summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-01-13 22:26:56 +0000
committerKarl Berry <karl@freefriends.org>2018-01-13 22:26:56 +0000
commit8321808ed1278e2b4fc5e6d58fcb1acecc4155c0 (patch)
tree3a919f39d8a823b139635052cb15b83bdbdfc8ef /Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm
parent4cc1370e31979d579fabb2561b6de643adde68d9 (diff)
latexindent (13jan18)
git-svn-id: svn://tug.org/texlive/trunk@46303 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm')
-rw-r--r--Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm200
1 files changed, 121 insertions, 79 deletions
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm
index bb0e47f2576..5f86e0008f5 100644
--- a/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm
+++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/GetYamlSettings.pm
@@ -20,6 +20,7 @@ use LatexIndent::Switches qw/%switches $is_m_switch_active $is_t_switch_active $
use YAML::Tiny; # interpret defaultSettings.yaml and other potential settings files
use File::Basename; # to get the filename and directory path
use File::HomeDir;
+use Log::Log4perl qw(get_logger :levels);
use Exporter qw/import/;
our @EXPORT_OK = qw/readSettings modify_line_breaks_settings get_indentation_settings_for_this_object get_every_or_custom_value get_indentation_information get_object_attribute_for_indentation_settings alignment_at_ampersand_settings %masterSettings/;
@@ -32,18 +33,32 @@ our %masterSettings;
# previously found settings is a hash, global to this module
our %previouslyFoundSettings;
+# default values for align at ampersand routine
+our @alignAtAmpersandInformation = ( {name=>"lookForAlignDelims",yamlname=>"delims",default=>1},
+ {name=>"alignDoubleBackSlash",default=>1},
+ {name=>"spacesBeforeDoubleBackSlash",default=>1},
+ {name=>"multiColumnGrouping",default=>0},
+ {name=>"alignRowsWithoutMaxDelims",default=>1},
+ {name=>"spacesBeforeAmpersand",default=>1},
+ {name=>"spacesAfterAmpersand",default=>1},
+ {name=>"justification",default=>"left"},
+ );
+
sub readSettings{
my $self = shift;
+ # read the default settings
$defaultSettings = YAML::Tiny->read( "$FindBin::RealBin/defaultSettings.yaml" );
- $self->logger("YAML settings read: defaultSettings.yaml",'heading');
- $self->logger("Reading defaultSettings.yaml from $FindBin::RealBin/defaultSettings.yaml");
+
+ # grab the logger object
+ my $logger = get_logger("Document");
+ $logger->info("*YAML settings read: defaultSettings.yaml\nReading defaultSettings.yaml from $FindBin::RealBin/defaultSettings.yaml");
# if latexindent.exe is invoked from TeXLive, then defaultSettings.yaml won't be in
# the same directory as it; we need to navigate to it
if(!$defaultSettings) {
$defaultSettings = YAML::Tiny->read( "$FindBin::RealBin/../../texmf-dist/scripts/latexindent/defaultSettings.yaml");
- $self->logger("Reading defaultSettings.yaml (2nd attempt, TeXLive, Windows) from $FindBin::RealBin/../../texmf-dist/scripts/latexindent/defaultSettings.yaml");
+ $logger->info("Reading defaultSettings.yaml (2nd attempt, TeXLive, Windows) from $FindBin::RealBin/../../texmf-dist/scripts/latexindent/defaultSettings.yaml");
}
# need to exit if we can't get defaultSettings.yaml
@@ -60,7 +75,7 @@ sub readSettings{
# we'll need the home directory a lot in what follows
my $homeDir = File::HomeDir->my_home;
- $self->logger("YAML settings read: indentconfig.yaml or .indentconfig.yaml",'heading');
+ $logger->info("*YAML settings read: indentconfig.yaml or .indentconfig.yaml") unless $switches{onlyDefault};
# get information about user settings- first check if indentconfig.yaml exists
my $indentconfig = "$homeDir/indentconfig.yaml";
@@ -70,39 +85,39 @@ sub readSettings{
# messages for indentconfig.yaml and/or .indentconfig.yaml
if ( -e $indentconfig and !$switches{onlyDefault}) {
- $self->logger("Reading path information from $indentconfig");
+ $logger->info("Reading path information from $indentconfig");
# if both indentconfig.yaml and .indentconfig.yaml exist
if ( -e File::HomeDir->my_home . "/indentconfig.yaml" and -e File::HomeDir->my_home . "/.indentconfig.yaml") {
- $self->logger("$homeDir/.indentconfig.yaml has been found, but $indentconfig takes priority");
+ $logger->info("$homeDir/.indentconfig.yaml has been found, but $indentconfig takes priority");
} elsif ( -e File::HomeDir->my_home . "/indentconfig.yaml" ) {
- $self->logger("(Alternatively $homeDir/.indentconfig.yaml can be used)");
+ $logger->info("(Alternatively $homeDir/.indentconfig.yaml can be used)");
} elsif ( -e File::HomeDir->my_home . "/.indentconfig.yaml" ) {
- $self->logger("(Alternatively $homeDir/indentconfig.yaml can be used)");
+ $logger->info("(Alternatively $homeDir/indentconfig.yaml can be used)");
}
-
+
# read the absolute paths from indentconfig.yaml
$userSettings = YAML::Tiny->read( "$indentconfig" );
# output the contents of indentconfig to the log file
- $self->logger(Dump \%{$userSettings->[0]});
-
+ $logger->info(Dump \%{$userSettings->[0]});
+
# update the absolute paths
@absPaths = @{$userSettings->[0]->{paths}};
} else {
if($switches{onlyDefault}) {
- $self->logger("Only default settings requested, not reading USER settings from $indentconfig");
- $self->logger("Ignoring $switches{readLocalSettings} (you used the -d switch)") if($switches{readLocalSettings});
- $self->logger("Ignoring the -y switch: $switches{yaml} (you used the -d switch)") if($switches{yaml});
+ $logger->info("*-d switch active: only default settings requested");
+ $logger->info("not reading USER settings from $indentconfig") if (-e $indentconfig);
+ $logger->info("Ignoring the -l switch: $switches{readLocalSettings} (you used the -d switch)") if($switches{readLocalSettings});
+ $logger->info("Ignoring the -y switch: $switches{yaml} (you used the -d switch)") if($switches{yaml});
$switches{readLocalSettings}=0;
$switches{yaml}=0;
} else {
# give the user instructions on where to put indentconfig.yaml or .indentconfig.yaml
- $self->logger("Home directory is $homeDir (didn't find either indentconfig.yaml or .indentconfig.yaml)");
- $self->logger("To specify user settings you would put indentconfig.yaml here: $homeDir/indentconfig.yaml");
- $self->logger("Alternatively, you can use the hidden file .indentconfig.yaml as: $homeDir/.indentconfig.yaml");
+ $logger->info("Home directory is $homeDir (didn't find either indentconfig.yaml or .indentconfig.yaml)\nTo specify user settings you would put indentconfig.yaml here: $homeDir/indentconfig.yaml\nAlternatively, you can use the hidden file .indentconfig.yaml as: $homeDir/.indentconfig.yaml");
}
}
+
# local settings can be called with a + symbol, for example
# -l=+myfile.yaml
# -l "+ myfile.yaml"
@@ -117,20 +132,20 @@ sub readSettings{
# will *only* load localSettings.yaml, and myfile.yaml will be ignored
my @localSettings;
- $self->logger("YAML settings read: -l switch",'heading') if $switches{readLocalSettings};
+ $logger->info("*YAML settings read: -l switch") if $switches{readLocalSettings};
# remove leading, trailing, and intermediate space
$switches{readLocalSettings} =~ s/^\h*//g;
$switches{readLocalSettings} =~ s/\h*$//g;
$switches{readLocalSettings} =~ s/\h*,\h*/,/g;
if($switches{readLocalSettings} =~ m/\+/){
- $self->logger("+ found in call for -l switch: will add localSettings.yaml");
+ $logger->info("+ found in call for -l switch: will add localSettings.yaml");
# + can be either at the beginning or the end, which determines if where the comma should go
my $commaAtBeginning = ($switches{readLocalSettings} =~ m/^\h*\+/ ? q() : ",");
my $commaAtEnd = ($switches{readLocalSettings} =~ m/^\h*\+/ ? "," : q());
$switches{readLocalSettings} =~ s/\h*\+\h*/$commaAtBeginning."localSettings.yaml".$commaAtEnd/e;
- $self->logger("New value of -l switch: $switches{readLocalSettings}");
+ $logger->info("New value of -l switch: $switches{readLocalSettings}");
}
# local settings can be separated by ,
@@ -138,8 +153,9 @@ sub readSettings{
# -l = myyaml1.yaml,myyaml2.yaml
# and in which case, we need to read them all
if($switches{readLocalSettings} =~ m/,/){
- $self->logger("Multiple localSettings found, separated by commas:");
+ $logger->info("Multiple localSettings found, separated by commas:");
@localSettings = split(/,/,$switches{readLocalSettings});
+ $logger->info(join(', ',@localSettings));
} else {
push(@localSettings,$switches{readLocalSettings}) if($switches{readLocalSettings});
}
@@ -161,21 +177,21 @@ sub readSettings{
# check for existence and non-emptiness
if ( (-e $_) and !(-z $_)) {
- $self->logger("Adding $_ to YAML read paths");
+ $logger->info("Adding $_ to YAML read paths");
push(@absPaths,"$_");
} elsif ( !(-e $_) ) {
- $self->logger("WARNING yaml file not found: $_ not found. Proceeding without it.");
+ $logger->warn("*yaml file not found: $_ not found. Proceeding without it.");
}
}
# heading for the log file
- $self->logger("YAML settings, reading from the following files:",'heading') if @absPaths;
+ $logger->info("*YAML settings, reading from the following files:") if @absPaths;
# read in the settings from each file
foreach my $settings (@absPaths) {
# check that the settings file exists and that it isn't empty
if (-e $settings and !(-z $settings)) {
- $self->logger("Reading USER settings from $settings");
+ $logger->info("Reading USER settings from $settings");
$userSettings = YAML::Tiny->read( "$settings" );
# if we can read userSettings
@@ -189,14 +205,14 @@ sub readSettings{
# if masterSettings already contains a *scalar* value in secondLevelKey
# then we need to delete it (test-cases/headings-first.tex with indentRules1.yaml first demonstrated this)
if(ref $masterSettings{$firstLevelKey}{$secondLevelKey} ne "HASH"){
- $self->logger("masterSettings{$firstLevelKey}{$secondLevelKey} currently contains a *scalar* value, but it needs to be updated with a hash (see $settings); deleting the scalar") if($is_t_switch_active);
+ $logger->trace("*masterSettings{$firstLevelKey}{$secondLevelKey} currently contains a *scalar* value, but it needs to be updated with a hash (see $settings); deleting the scalar") if($is_t_switch_active);
delete $masterSettings{$firstLevelKey}{$secondLevelKey} ;
}
while(my ($thirdLevelKey,$thirdLevelValue) = each %{$secondLevelValue}) {
if (ref $thirdLevelValue eq "HASH"){
# similarly for third level
if (ref $masterSettings{$firstLevelKey}{$secondLevelKey}{$thirdLevelKey} ne "HASH"){
- $self->logger("masterSettings{$firstLevelKey}{$secondLevelKey}{$thirdLevelKey} currently contains a *scalar* value, but it needs to be updated with a hash (see $settings); deleting the scalar") if($is_t_switch_active);
+ $logger->trace("*masterSettings{$firstLevelKey}{$secondLevelKey}{$thirdLevelKey} currently contains a *scalar* value, but it needs to be updated with a hash (see $settings); deleting the scalar") if($is_t_switch_active);
delete $masterSettings{$firstLevelKey}{$secondLevelKey}{$thirdLevelKey} ;
}
while(my ($fourthLevelKey,$fourthLevelValue) = each %{$thirdLevelValue}) {
@@ -217,21 +233,21 @@ sub readSettings{
# output settings to $logfile
if($masterSettings{logFilePreferences}{showEveryYamlRead}){
- $self->logger(Dump \%{$userSettings->[0]});
+ $logger->info(Dump \%{$userSettings->[0]});
} else {
- $self->logger("Not showing settings in the log file (see showEveryYamlRead and showAmalgamatedSettings).");
+ $logger->info("Not showing settings in the log file (see showEveryYamlRead and showAmalgamatedSettings).");
}
} else {
# otherwise print a warning that we can not read userSettings.yaml
- $self->logger("WARNING $settings contains invalid yaml format- not reading from it");
+ $logger->warn("*$settings contains invalid yaml format- not reading from it");
}
} else {
# otherwise keep going, but put a warning in the log file
- $self->logger("WARNING: $homeDir/indentconfig.yaml");
+ $logger->warn("*$homeDir/indentconfig.yaml");
if (-z $settings) {
- $self->logger("specifies $settings but this file is EMPTY -- not reading from it");
+ $logger->info("specifies $settings but this file is EMPTY -- not reading from it");
} else {
- $self->logger("specifies $settings but this file does not exist - unable to read settings from this file");
+ $logger->info("specifies $settings but this file does not exist - unable to read settings from this file");
}
}
}
@@ -239,16 +255,16 @@ sub readSettings{
# read settings from -y|--yaml switch
if($switches{yaml}){
# report to log file
- $self->logger("YAML settings read: -y switch",'heading');
+ $logger->info("*YAML settings read: -y switch");
# remove any horizontal space before or after , OR : OR ; or at the beginning or end of the switch value
- $switches{yaml} =~ s/\h*(,|:|;)\h*/$1/g;
+ $switches{yaml} =~ s/\h*(,|(?<!\\):|;)\h*/$1/g;
$switches{yaml} =~ s/^\h*//g;
# store settings, possibly multiple ones split by commas
my @yamlSettings;
- if($switches{yaml} =~ m/,/){
- @yamlSettings = split(/,/,$switches{yaml});
+ if($switches{yaml} =~ m/(?<!\\),/){
+ @yamlSettings = split(/(?<!\\),/,$switches{yaml});
} else {
push(@yamlSettings,$switches{yaml});
}
@@ -274,8 +290,8 @@ sub readSettings{
$settingsCounter++;
# check for a match of the ;
- if($_ =~ m/;/){
- my (@subfield) = split(/;/,$_);
+ if($_ =~ m/(?<!\\);/){
+ my (@subfield) = split(/(?<!\\);/,$_);
# the content up to the first ; is called the 'root'
my $root = shift @subfield;
@@ -312,7 +328,7 @@ sub readSettings{
# reform the root
$root = join(":",@keysValues);
- $self->logger("Sub-field detected (; present) and the root is: $root") if $is_t_switch_active;
+ $logger->trace("*Sub-field detected (; present) and the root is: $root") if $is_t_switch_active;
# now we need to attach the $root back together with any subfields
foreach(@subfield){
@@ -322,18 +338,22 @@ sub readSettings{
# increment the counter
$settingsCounter++;
}
- $self->logger("-y switch value interpreted as: ".join(',',@yamlSettings));
+ $logger->info("-y switch value interpreted as: ".join(',',@yamlSettings));
}
}
# loop through each of the settings specified in the -y switch
foreach(@yamlSettings){
# split each value at semi-colon
- my (@keysValues) = split(/:/,$_);
+ my (@keysValues) = split(/(?<!\\):/,$_);
# $value will always be the last element
my $value = $keysValues[-1];
+ # it's possible that the 'value' will contain an escaped
+ # semi-colon, so we replace it with just a semi-colon
+ $value =~ s/\\:/:/;
+
# horizontal space needs special treatment
if($value =~ m/^(?:"|')(\h*)(?:"|')$/){
# pure horizontal space
@@ -348,20 +368,20 @@ sub readSettings{
if(scalar(@keysValues) == 2){
# for example, -y="defaultIndent: ' '"
my $key = $keysValues[0];
- $self->logger("Updating masterSettings with $key: $value");
+ $logger->info("Updating masterSettings with $key: $value");
$masterSettings{$key} = $value;
} elsif(scalar(@keysValues) == 3){
# for example, -y="indentRules: one: '\t\t\t\t'"
my $parent = $keysValues[0];
my $child = $keysValues[1];
- $self->logger("Updating masterSettings with $parent: $child: $value");
+ $logger->info("Updating masterSettings with $parent: $child: $value");
$masterSettings{$parent}{$child} = $value;
} elsif(scalar(@keysValues) == 4){
# for example, -y='modifyLineBreaks : environments: EndStartsOnOwnLine:3' -m
my $parent = $keysValues[0];
my $child = $keysValues[1];
my $grandchild = $keysValues[2];
- $self->logger("Updating masterSettings with $parent: $child: $grandchild: $value");
+ $logger->info("Updating masterSettings with $parent: $child: $grandchild: $value");
$masterSettings{$parent}{$child}{$grandchild} = $value;
} elsif(scalar(@keysValues) == 5){
# for example, -y='modifyLineBreaks : environments: one: EndStartsOnOwnLine:3' -m
@@ -369,7 +389,7 @@ sub readSettings{
my $child = $keysValues[1];
my $grandchild = $keysValues[2];
my $greatgrandchild = $keysValues[3];
- $self->logger("Updating masterSettings with $parent: $child: $grandchild: $greatgrandchild: $value");
+ $logger->info("Updating masterSettings with $parent: $child: $grandchild: $greatgrandchild: $value");
$masterSettings{$parent}{$child}{$grandchild}{$greatgrandchild} = $value;
}
}
@@ -379,8 +399,8 @@ sub readSettings{
# which details the overall state of the settings modified
# from the default in various user files
if($masterSettings{logFilePreferences}{showAmalgamatedSettings}){
- $self->logger("Amalgamated/overall settings to be used:",'heading');
- $self->logger(Dump \%masterSettings);
+ $logger->info("Amalgamated/overall settings to be used:");
+ $logger->info(Dump \%masterSettings);
}
return;
@@ -392,12 +412,15 @@ sub get_indentation_settings_for_this_object{
# create a name for previously found settings
my $storageName = ${$self}{name}.${$self}{modifyLineBreaksYamlName}.(defined ${$self}{storageNameAppend}?${$self}{storageNameAppend}:q());
+ # grab the logging object
+ my $logger = get_logger("Document");
+
# check for storage of repeated objects
if ($previouslyFoundSettings{$storageName}){
- $self->logger("Using stored settings for $storageName") if($is_t_switch_active);
+ $logger->trace("*Using stored settings for $storageName") if($is_t_switch_active);
} else {
my $name = ${$self}{name};
- $self->logger("Storing settings for $storageName") if($is_t_switch_active);
+ $logger->trace("Storing settings for $storageName") if($is_t_switch_active);
# check for noAdditionalIndent and indentRules
# otherwise use defaultIndent
@@ -420,11 +443,9 @@ sub get_indentation_settings_for_this_object{
);
# don't forget alignment settings!
- ${${previouslyFoundSettings}{$storageName}}{lookForAlignDelims} = ${$self}{lookForAlignDelims} if(defined ${$self}{lookForAlignDelims});
- ${${previouslyFoundSettings}{$storageName}}{alignDoubleBackSlash} = ${$self}{alignDoubleBackSlash} if(defined ${$self}{alignDoubleBackSlash});
- ${${previouslyFoundSettings}{$storageName}}{spacesBeforeDoubleBackSlash} = ${$self}{spacesBeforeDoubleBackSlash} if(defined ${$self}{spacesBeforeDoubleBackSlash});
- ${${previouslyFoundSettings}{$storageName}}{multiColumnGrouping} = ${$self}{multiColumnGrouping} if(defined ${$self}{multiColumnGrouping});
- ${${previouslyFoundSettings}{$storageName}}{alignRowsWithoutMaxDelims} = ${$self}{alignRowsWithoutMaxDelims} if(defined ${$self}{alignRowsWithoutMaxDelims});
+ foreach (@alignAtAmpersandInformation){
+ ${${previouslyFoundSettings}{$storageName}}{${$_}{name}} = ${$self}{${$_}{name}} if(defined ${$self}{${$_}{name}});
+ }
# some objects, e.g ifElseFi, can have extra assignments, e.g ElseStartsOnOwnLine
# these need to be stored as well!
@@ -432,6 +453,10 @@ sub get_indentation_settings_for_this_object{
${${previouslyFoundSettings}{$storageName}}{$_} = ${$self}{$_};
}
+ # log file information
+ $logger->trace("Settings for $name (stored for future use):") if $is_tt_switch_active;
+ $logger->trace(Dump \%{${previouslyFoundSettings}{$storageName}}) if $is_tt_switch_active;
+
}
# append indentation settings to the current object
@@ -461,17 +486,25 @@ sub alignment_at_ampersand_settings{
return unless ${$masterSettings{lookForAlignDelims}}{$name};
if(ref ${$masterSettings{lookForAlignDelims}}{$name} eq "HASH"){
- ${$self}{lookForAlignDelims} = (defined ${${$masterSettings{lookForAlignDelims}}{$name}}{delims} ) ? ${${$masterSettings{lookForAlignDelims}}{$name}}{delims} : 1;
- ${$self}{alignDoubleBackSlash} = (defined ${${$masterSettings{lookForAlignDelims}}{$name}}{alignDoubleBackSlash} ) ? ${${$masterSettings{lookForAlignDelims}}{$name}}{alignDoubleBackSlash} : 1;
- ${$self}{spacesBeforeDoubleBackSlash} = (defined ${${$masterSettings{lookForAlignDelims}}{$name}}{spacesBeforeDoubleBackSlash} ) ? ${${$masterSettings{lookForAlignDelims}}{$name}}{spacesBeforeDoubleBackSlash} : -1;
- ${$self}{multiColumnGrouping} = (defined ${${$masterSettings{lookForAlignDelims}}{$name}}{multiColumnGrouping} ) ? ${${$masterSettings{lookForAlignDelims}}{$name}}{multiColumnGrouping} : 0;
- ${$self}{alignRowsWithoutMaxDelims} = (defined ${${$masterSettings{lookForAlignDelims}}{$name}}{alignRowsWithoutMaxDelims} ) ? ${${$masterSettings{lookForAlignDelims}}{$name}}{alignRowsWithoutMaxDelims} : 1;
+ # specified as a hash, e.g
+ #
+ # lookForAlignDelims:
+ # tabular:
+ # delims: 1
+ # alignDoubleBackSlash: 1
+ # spacesBeforeDoubleBackSlash: 2
+ foreach (@alignAtAmpersandInformation){
+ my $yamlname = (defined ${$_}{yamlname} ? ${$_}{yamlname}: ${$_}{name});
+ ${$self}{${$_}{name}} = (defined ${${$masterSettings{lookForAlignDelims}}{$name}}{$yamlname} ) ? ${${$masterSettings{lookForAlignDelims}}{$name}}{$yamlname} : ${$_}{default};
+ }
} else {
- ${$self}{lookForAlignDelims} = 1;
- ${$self}{alignDoubleBackSlash} = 1;
- ${$self}{spacesBeforeDoubleBackSlash} = -1;
- ${$self}{multiColumnGrouping} = 0;
- ${$self}{alignRowsWithoutMaxDelims} = 1;
+ # specified as a scalar, e.g
+ #
+ # lookForAlignDelims:
+ # tabular: 1
+ foreach (@alignAtAmpersandInformation){
+ ${$self}{${$_}{name}} = ${$_}{default};
+ }
}
return;
}
@@ -482,8 +515,11 @@ sub modify_line_breaks_settings{
my $self = shift;
+ # grab the logging object
+ my $logger = get_logger("Document");
+
# details to the log file
- $self->logger("-m modifylinebreaks switch active, looking for settings for ${$self}{name} ",'heading') if $is_t_switch_active;
+ $logger->trace("*-m modifylinebreaks switch active, looking for settings for ${$self}{name} ") if $is_t_switch_active;
# some objects, e.g ifElseFi, can have extra assignments, e.g ElseStartsOnOwnLine
my @toBeAssignedTo = ${$self}{additionalAssignments} ? @{${$self}{additionalAssignments}} : ();
@@ -522,11 +558,11 @@ sub modify_line_breaks_settings{
my $name = ($YamlName =~ m/Arguments/) ? ${$self}{parent} : ${$self}{name};
if(ref ${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{$YamlName} eq "HASH"){
- $self->logger("$YamlName specified with fields in removeParagraphLineBreaks, looking for $name") if $is_t_switch_active;
+ $logger->trace("*$YamlName specified with fields in removeParagraphLineBreaks, looking for $name") if $is_t_switch_active;
${$self}{removeParagraphLineBreaks} = ${${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{$YamlName}}{$name}||0;
} else {
if(defined ${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{$YamlName}){
- $self->logger("$YamlName specified with just a number in removeParagraphLineBreaks ${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{$YamlName}") if $is_t_switch_active;
+ $logger->trace("*$YamlName specified with just a number in removeParagraphLineBreaks ${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{$YamlName}") if $is_t_switch_active;
${$self}{removeParagraphLineBreaks} = ${$masterSettings{modifyLineBreaks}{removeParagraphLineBreaks}}{$YamlName};
}
}
@@ -540,9 +576,12 @@ sub get_every_or_custom_value{
my $toBeAssignedTo = $input{toBeAssignedTo};
my $toBeAssignedToAlias = $input{toBeAssignedToAlias};
+ # grab the logging object
+ my $logger = get_logger("Document");
+
# alias
if(${$self}{aliases}{$toBeAssignedTo}){
- $self->logger("aliased $toBeAssignedTo using ${$self}{aliases}{$toBeAssignedTo}") if($is_t_switch_active);
+ $logger->trace("aliased $toBeAssignedTo using ${$self}{aliases}{$toBeAssignedTo}") if($is_t_switch_active);
}
# name of the object in the modifyLineBreaks yaml (e.g environments, ifElseFi, etc)
@@ -557,12 +596,12 @@ sub get_every_or_custom_value{
# check for the *custom* value
if (defined $customValue){
- $self->logger("$name: $toBeAssignedToAlias=$customValue, (*custom* value) adjusting $toBeAssignedTo") if($is_t_switch_active);
+ $logger->trace("$name: $toBeAssignedToAlias=$customValue, (*custom* value) adjusting $toBeAssignedTo") if($is_t_switch_active);
${$self}{$toBeAssignedTo} = $customValue !=0 ? $customValue : undef;
} else {
# check for the *every* value
if (defined $everyValue and $everyValue != 0){
- $self->logger("$name: $toBeAssignedToAlias=$everyValue, (*every* value) adjusting $toBeAssignedTo") if($is_t_switch_active);
+ $logger->trace("$name: $toBeAssignedToAlias=$everyValue, (*every* value) adjusting $toBeAssignedTo") if($is_t_switch_active);
${$self}{$toBeAssignedTo} = $everyValue;
}
}
@@ -619,24 +658,27 @@ sub get_indentation_information{
# if the YamlName is not optionalArguments, mandatoryArguments, heading (possibly others) then assume we're looking for 'body'
my $YamlName = $self->get_object_attribute_for_indentation_settings;
+ # grab the logging object
+ my $logger = get_logger("Document");
+
my $indentationInformation;
foreach my $indentationAbout ("noAdditionalIndent","indentRules"){
# check that the 'thing' is defined
if(defined ${$masterSettings{$indentationAbout}}{$name}){
if(ref ${$masterSettings{$indentationAbout}}{$name} eq "HASH"){
- $self->logger("$indentationAbout indentation specified with multiple fields for $name, searching for $name: $YamlName (see $indentationAbout)") if $is_t_switch_active ;
+ $logger->trace("$indentationAbout indentation specified with multiple fields for $name, searching for $name: $YamlName (see $indentationAbout)") if $is_t_switch_active ;
$indentationInformation = ${${$masterSettings{$indentationAbout}}{$name}}{$YamlName};
} else {
$indentationInformation = ${$masterSettings{$indentationAbout}}{$name};
- $self->logger("$indentationAbout indentation specified for $name (for *all* fields, body, optionalArguments, mandatoryArguments, afterHeading), using '$indentationInformation' (see $indentationAbout)") if $is_t_switch_active ;
+ $logger->trace("$indentationAbout indentation specified for $name (for *all* fields, body, optionalArguments, mandatoryArguments, afterHeading), using '$indentationInformation' (see $indentationAbout)") if $is_t_switch_active ;
}
# return, after performing an integrity check
if(defined $indentationInformation){
if($indentationAbout eq "noAdditionalIndent" and $indentationInformation == 1){
- $self->logger("Found! Using '' (see $indentationAbout)") if $is_t_switch_active;
+ $logger->trace("Found! Using '' (see $indentationAbout)") if $is_t_switch_active;
return q();
} elsif($indentationAbout eq "indentRules" and $indentationInformation=~m/^\h*$/){
- $self->logger("Found! Using '$indentationInformation' (see $indentationAbout)") if $is_t_switch_active;
+ $logger->trace("Found! Using '$indentationInformation' (see $indentationAbout)") if $is_t_switch_active;
return $indentationInformation ;
}
}
@@ -651,20 +693,20 @@ sub get_indentation_information{
my $globalInformation = $indentationAbout."Global";
next if(!(defined ${$masterSettings{$globalInformation}}{$YamlName}));
if( ($globalInformation eq "noAdditionalIndentGlobal") and ${$masterSettings{$globalInformation}}{$YamlName}==1){
- $self->logger("$globalInformation specified for $YamlName (see $globalInformation)") if $is_t_switch_active;
+ $logger->trace("$globalInformation specified for $YamlName (see $globalInformation)") if $is_t_switch_active;
return q();
} elsif($globalInformation eq "indentRulesGlobal") {
if(${$masterSettings{$globalInformation}}{$YamlName}=~m/^\h*$/){
- $self->logger("$globalInformation specified for $YamlName (see $globalInformation)") if $is_t_switch_active;
+ $logger->trace("$globalInformation specified for $YamlName (see $globalInformation)") if $is_t_switch_active;
return ${$masterSettings{$globalInformation}}{$YamlName};
} else {
- $self->logger("$globalInformation specified (${$masterSettings{$globalInformation}}{$YamlName}) for $YamlName, but it needs to only contain horizontal space -- I'm ignoring this one") if $is_t_switch_active;
+ $logger->trace("$globalInformation specified (${$masterSettings{$globalInformation}}{$YamlName}) for $YamlName, but it needs to only contain horizontal space -- I'm ignoring this one") if $is_t_switch_active;
}
}
}
# return defaultIndent, by default
- $self->logger("Using defaultIndent for $name") if $is_t_switch_active;
+ $logger->trace("Using defaultIndent for $name") if $is_t_switch_active;
return $masterSettings{defaultIndent};
}