lib/timber/contexts/system.rb in timber-2.6.2 vs lib/timber/contexts/system.rb in timber-3.0.0
- old
+ new
@@ -6,31 +6,24 @@
# The system context tracks OS level process information, such as the process ID.
#
# @note This is tracked automatically in {CurrentContext}. When the current context
# is initialized, the system context gets added automatically.
class System < Context
- HOSTNAME_MAX_BYTES = 256.freeze
-
- @keyspace = :system
-
attr_reader :hostname, :pid
def initialize(attributes)
- normalizer = Util::AttributeNormalizer.new(attributes)
- @hostname = normalizer.fetch(:hostname, :string, :limit => HOSTNAME_MAX_BYTES)
- @pid = normalizer.fetch(:pid, :integer)
+ @hostname = attributes[:hostname]
+ @pid = attributes[:pid]
end
# Builds a hash representation containing simple objects, suitable for serialization (JSON).
def to_hash
- @to_hash ||= Util::NonNilHashBuilder.build do |h|
- h.add(:hostname, hostname)
- h.add(:pid, pid)
- end
+ @to_hash ||= {
+ system: Util::NonNilHashBuilder.build do |h|
+ h.add(:hostname, hostname)
+ h.add(:pid, pid)
+ end
+ }
end
-
- def as_json(_options = {})
- to_hash
- end
end
end
-end
\ No newline at end of file
+end