Class: Timber::Contexts::System

Inherits:
Timber::Context
  • Object
show all
Defined in:
lib/timber/contexts/system.rb

Overview

Note:

This is tracked automatically in Timber::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

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ System

Returns a new instance of System.



15
16
17
18
# File 'lib/timber/contexts/system.rb', line 15

def initialize(attributes)
  @hostname = attributes[:hostname]
  @pid = Timber::Util::Object.try(attributes[:pid], :to_i)
end

Instance Attribute Details

#hostnameObject (readonly)

Returns the value of attribute hostname.



13
14
15
# File 'lib/timber/contexts/system.rb', line 13

def hostname
  @hostname
end

#pidObject (readonly)

Returns the value of attribute pid.



13
14
15
# File 'lib/timber/contexts/system.rb', line 13

def pid
  @pid
end

Instance Method Details

#as_json(_options = {}) ⇒ Object

Builds a hash representation containing simple objects, suitable for serialization (JSON).



21
22
23
# File 'lib/timber/contexts/system.rb', line 21

def as_json(_options = {})
  {hostname: hostname, pid: pid}
end