Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

(maint) Enable logging for all `puppet doc` commands #1580

Closed
wants to merge 1 commit into from

4 participants

@adrienthebo
Owner

Without this commit the --debug and --verbose flags can only be used
with the rdoc mode and doesn't interact with the other documentation
types. This commit extracts the logging configuration to apply to all
documentation modes.

In addition this defaults the log level to :warning. Since warning and
above messages will be emitted on stderr this will not affect the normal
operation of the puppet doc command. Using --debug or --verbose will
emit messages on stdout, so they should not be used while
programmatically generating docs.

@puppetcla

CLA Signed by adrienthebo on 2011-03-07 21:00:00 -0800

@adrienthebo
Owner

There are definitely some broken specs in here, but I'm having some trouble reproducing on my development machine. I'm investigating.

@adrienthebo adrienthebo (maint) Enable logging for all `puppet doc` commands
Without this commit the --debug and --verbose flags can only be used
with the rdoc mode and doesn't interact with the other documentation
types. This commit extracts the logging configuration to apply to all
documentation modes.

In addition this defaults the log level to :warning. Since warning and
above messages will be emitted on stderr this will not affect the normal
operation of the `puppet doc` command. Using --debug or --verbose will
emit messages on stdout, so they should not be used while
programmatically generating docs.
a0ac536
@jeffmccune jeffmccune closed this pull request from a commit
@jeffmccune jeffmccune Merge branch 'adrienthebo-maint-enable_logging_for_all_docs'
* adrienthebo-maint-enable_logging_for_all_docs:
  (maint) Enable logging for all `puppet doc` commands

closes #1580
be09a83
@jeffmccune
Owner

summary: Merged into master as be09a83. This should be released in Puppet 3.2. Thanks again for the contribution!

-Jeff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 3, 2013
  1. @adrienthebo

    (maint) Enable logging for all `puppet doc` commands

    adrienthebo authored
    Without this commit the --debug and --verbose flags can only be used
    with the rdoc mode and doesn't interact with the other documentation
    types. This commit extracts the logging configuration to apply to all
    documentation modes.
    
    In addition this defaults the log level to :warning. Since warning and
    above messages will be emitted on stderr this will not affect the normal
    operation of the `puppet doc` command. Using --debug or --verbose will
    emit messages on stdout, so they should not be used while
    programmatically generating docs.
This page is out of date. Refresh to see the latest.
Showing with 68 additions and 41 deletions.
  1. +13 −9 lib/puppet/application/doc.rb
  2. +55 −32 spec/unit/application/doc_spec.rb
View
22 lib/puppet/application/doc.rb
@@ -235,6 +235,8 @@ def setup
else
setup_reference
end
+
+ setup_logging
end
def setup_reference
@@ -261,16 +263,18 @@ def setup_rdoc(dummy_argument=:work_arround_for_ruby_GC_bug)
Puppet.settings.handlearg(option[:opt], option[:arg])
end
end
+ end
- # Handle the logging settings.
- if options[:debug] or options[:verbose]
- if options[:debug]
- Puppet::Util::Log.level = :debug
- else
- Puppet::Util::Log.level = :info
- end
-
- Puppet::Util::Log.newdestination(:console)
+ def setup_logging
+ # Handle the logging settings.
+ if options[:debug]
+ Puppet::Util::Log.level = :debug
+ elsif options[:verbose]
+ Puppet::Util::Log.level = :info
+ else
+ Puppet::Util::Log.level = :warning
end
+
+ Puppet::Util::Log.newdestination(:console)
end
end
View
87 spec/unit/application/doc_spec.rb
@@ -143,6 +143,61 @@
@doc.setup
end
+ describe "configuring logging" do
+ before :each do
+ Puppet::Util::Log.stubs(:newdestination)
+ end
+
+ describe "with --debug" do
+ before do
+ @doc.options[:debug] = true
+ end
+
+ it "should set log level to debug" do
+ @doc.setup
+ Puppet::Util::Log.level.should == :debug
+ end
+
+ it "should set log destination to console" do
+ Puppet::Util::Log.expects(:newdestination).with(:console)
+ @doc.setup
+ end
+ end
+
+ describe "with --verbose" do
+ before do
+ @doc.options[:verbose] = true
+ end
+
+ it "should set log level to info" do
+ @doc.setup
+ Puppet::Util::Log.level.should == :info
+ end
+
+ it "should set log destination to console" do
+ Puppet::Util::Log.expects(:newdestination).with(:console)
+ @doc.setup
+ end
+ end
+
+ describe "without --debug or --verbose" do
+ before do
+ @doc.options[:debug] = false
+ @doc.options[:verbose] = false
+ end
+
+ it "should set log level to warning" do
+ @doc.setup
+ Puppet::Util::Log.level.should == :warning
+ end
+
+ it "should set log destination to console" do
+ Puppet::Util::Log.expects(:newdestination).with(:console)
+ @doc.setup
+ end
+ end
+ end
+
describe "in non-rdoc mode" do
it "should get all non-dynamic reference if --all" do
@doc.options[:all] = true
@@ -163,10 +218,6 @@
end
describe "in rdoc mode" do
- before :each do
- Puppet::Util::Log.stubs(:newdestination)
- end
-
describe "when there are unknown args" do
it "should expand --modulepath if any" do
@doc.unknown_args = [ { :opt => "--modulepath", :arg => "path" } ]
@@ -199,34 +250,6 @@
@doc.setup_rdoc
end
-
- it "should set log level to debug if --debug" do
- @doc.options[:debug] = true
- @doc.setup_rdoc
- Puppet::Util::Log.level.should == :debug
- end
-
- it "should set log level to info if --verbose" do
- @doc.options[:verbose] = true
- @doc.setup_rdoc
- Puppet::Util::Log.level.should == :info
- end
-
- it "should set log destination to console if --verbose" do
- @doc.options[:verbose] = true
-
- Puppet::Util::Log.expects(:newdestination).with(:console)
-
- @doc.setup_rdoc
- end
-
- it "should set log destination to console if --debug" do
- @doc.options[:debug] = true
-
- Puppet::Util::Log.expects(:newdestination).with(:console)
-
- @doc.setup_rdoc
- end
end
end
Something went wrong with that request. Please try again.