From 30fa8412541b34fa0fd5ef332f96a4474e7f6c3b Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Mon, 12 Nov 2018 23:35:26 +1300 Subject: [PATCH] Add verbose output about status of config files --- bin/mythtv-status | 18 +++++++++++++----- debian/changelog | 4 ++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/bin/mythtv-status b/bin/mythtv-status index 10aff76..e916e36 100755 --- a/bin/mythtv-status +++ b/bin/mythtv-status @@ -31,16 +31,22 @@ use Encode; # Try and load a config file first, and then allow the command line # to override what is in the config file. -my ($c); +my $c; if (eval("{ local \$SIG{__DIE__}; require Config::Auto; }")) { $c = eval { Config::Auto::parse("mythtv-status.yml", format => 'yaml') }; - if ($@ && $@ !~ /^No config file found/) { + if ($@) { # Die on any issues loading the config file, apart from it not existing. - die $@; + if ($@ =~ /^No config file found/) { + $c->{'config_file_loaded'} = 0; + } else { + die $@; + } + } else { + $c->{'config_file_loaded'} = 1; } } @@ -560,8 +566,10 @@ if ($c->{'date'}) { } if ($verbose) { - print "Today: $today\n"; - print "Tomorrow: $tomorrow\n"; + print "Today: $today\n"; + print "Tomorrow: $tomorrow\n"; + print "Config::Auto module: " . (defined $INC{'Config/Auto.pm'} ? 'Loaded' : 'Not Loaded') . "\n"; + print "Config file loaded: " . ($c->{'config_file_loaded'} ? 'Yes' : 'No') . "\n"; } # If we're in return code only mode then we disable all blocks diff --git a/debian/changelog b/debian/changelog index ecfc657..6d79a17 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,10 @@ mythtv-status (0.10.8-1.1) UNRELEASED; urgency=medium Eric Wilde * Since a config file is optional, make Config::Auto optional. + Andrew Ruthven + * In verbose mode, show if Config::Auto is loaded and if we load a config + file, this is useful information for when I'm debugging issues. + -- Andrew Ruthven Mon, 12 Nov 2018 23:19:17 +1300 mythtv-status (0.10.8-1) unstable; urgency=low -- 2.30.2