Skip to content

Commit

Permalink
enable metadata to be got and set
Browse files Browse the repository at this point in the history
Signed-off-by: Thom May <[email protected]>
  • Loading branch information
Thom May committed Feb 28, 2018
1 parent cf0d1b9 commit b8b4391
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
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
5 changes: 5 additions & 0 deletions spec/mixlib/log_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,9 @@ def #{method_name}(message)
expect(opened_files_count_after).to eq(opened_files_count_before + 1)
end

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

end

0 comments on commit b8b4391

Please sign in to comment.