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

enable metadata to be got and set #32

Merged
merged 1 commit into from
Feb 28, 2018
Merged
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
3 changes: 3 additions & 0 deletions lib/mixlib/log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module Log
def reset!
close!
@logger, @loggers = nil, nil
@metadata = {}
end

# An Array of log devices that will be logged to. Defaults to just the default
Expand Down Expand Up @@ -92,6 +93,8 @@ def configured?
@configured
end

attr_accessor :metadata

# Sets the level for the Logger object by symbol. Valid arguments are:
#
# :trace
Expand Down
1 change: 1 addition & 0 deletions lib/mixlib/log/child.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Child
include Mixlib::Log::Logging

attr_reader :parent
attr_accessor :metadata
def initialize(parent, metadata = {})
@parent = parent
@metadata = metadata
Expand Down
6 changes: 6 additions & 0 deletions spec/mixlib/log_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,10 @@ def #{method_name}(message)
expect(Logit.fatal("hello")).to be_nil
end
end

it "should set metadata correctly" do
Logit.metadata = { test: "data" }
expect(Logit.metadata).to eql({ test: "data" })
end

end