Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Issue #125 #126

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,33 @@ Attribute | Description |
--------- |------------- |----- |--------
name | Some useful information about the license. Similar to ruby_block. | String | name

## nexus\_logging

Resource provider for setting level for logger

### Actions
Action | Description | Default
------- |------------- |---------
set_level| Set logger level | Yes

### Attributes
Attribute | Description | Type | Default
--------- |------------- |----- |--------
name | Name of LOGGER that would be adjusted | String | name
level | Level to set for LOGGER [name] | String | info

#### Logging Example

Below is how you should configure logger to get information who has downloaded which artifact:

nexus_logging "org.eclipse.jetty.server.Server" do
level "debug"
end

nexus_logging "org.sonatype.security.internal.UserIdMdcHelper" do
level "trace"
end

## nexus\_proxy

Resource provider for manipulating the Nexus' settings for Smart Proxy.
Expand Down
12 changes: 7 additions & 5 deletions providers/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,25 @@ def load_current_resource

run_context.include_recipe "nexus::cli"
Chef::Nexus.ensure_nexus_available(node)

@current_resource
end

action :set_level do

unless same_logging_level?

Chef::Nexus.nexus(node).set_logger_level(new_resource.level)
Chef::Nexus.nexus(node).set_logger_level(new_resource.name, new_resource.level)
new_resource.updated_by_last_action(true)
end
end

private

def same_logging_level?
require 'json'
logging_info = JSON.parse(Chef::Nexus.nexus(node).get_logging_info)
logging_info["data"]["rootLoggerLevel"] == new_resource.level
log_levels[new_resource.name] == new_resource.level.upcase
end

def log_levels
require 'json'
JSON.parse(Chef::Nexus.nexus(node).get_logging_info)
end
3 changes: 2 additions & 1 deletion resources/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
actions :set_level
default_action :set_level

attribute :level, :kind_of => String, :name_attribute => true, :equal_to => ["debug", "error", "info"], :default => "info"
attribute :name, :kind_of => String, :name_attribute => true
attribute :level, :kind_of => String, :equal_to => %w(trace debug info warn error off default), :default => "info"