Class: Logtail::Contexts::System
- Inherits:
-
Logtail::Context
- Object
- Logtail::Context
- Logtail::Contexts::System
- Defined in:
- lib/logtail/contexts/system.rb
Overview
Note:
This is tracked automatically in Logtail::CurrentContext. When the current context is initialized, the system context gets added automatically.
The system context tracks OS level process information, such as the process ID.
Instance Attribute Summary collapse
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ System
constructor
A new instance of System.
-
#to_hash ⇒ Object
Builds a hash representation containing simple objects, suitable for serialization (JSON).
Constructor Details
#initialize(attributes) ⇒ System
Returns a new instance of System.
13 14 15 16 |
# File 'lib/logtail/contexts/system.rb', line 13 def initialize(attributes) @hostname = attributes[:hostname] @pid = attributes[:pid] end |
Instance Attribute Details
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
11 12 13 |
# File 'lib/logtail/contexts/system.rb', line 11 def hostname @hostname end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
11 12 13 |
# File 'lib/logtail/contexts/system.rb', line 11 def pid @pid end |
Instance Method Details
#to_hash ⇒ Object
Builds a hash representation containing simple objects, suitable for serialization (JSON).
19 20 21 22 23 24 25 26 |
# File 'lib/logtail/contexts/system.rb', line 19 def to_hash @to_hash ||= { system: Util::NonNilHashBuilder.build do |h| h.add(:hostname, hostname) h.add(:pid, pid) end } end |