summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/mixlib/log.rb3
-rw-r--r--lib/mixlib/log/child.rb1
-rw-r--r--spec/mixlib/log_spec.rb6
3 files changed, 10 insertions, 0 deletions
diff --git a/lib/mixlib/log.rb b/lib/mixlib/log.rb
index 7193583..c605148 100644
--- a/lib/mixlib/log.rb
+++ b/lib/mixlib/log.rb
@@ -31,6 +31,7 @@ module Mixlib
def reset!
close!
@logger, @loggers = nil, nil
+ @metadata = {}
end
# An Array of log devices that will be logged to. Defaults to just the default
@@ -92,6 +93,8 @@ module Mixlib
@configured
end
+ attr_accessor :metadata
+
# Sets the level for the Logger object by symbol. Valid arguments are:
#
# :trace
diff --git a/lib/mixlib/log/child.rb b/lib/mixlib/log/child.rb
index 971c956..56376c5 100644
--- a/lib/mixlib/log/child.rb
+++ b/lib/mixlib/log/child.rb
@@ -22,6 +22,7 @@ module Mixlib
include Mixlib::Log::Logging
attr_reader :parent
+ attr_accessor :metadata
def initialize(parent, metadata = {})
@parent = parent
@metadata = metadata
diff --git a/spec/mixlib/log_spec.rb b/spec/mixlib/log_spec.rb
index 5798a90..60da408 100644
--- a/spec/mixlib/log_spec.rb
+++ b/spec/mixlib/log_spec.rb
@@ -213,4 +213,10 @@ RSpec.describe Mixlib::Log do
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