Sha256: 7613c5789039f2dbe91403b8bd96cbaf22e99f2c3d8a599073b8585c15c6b1dd

Contents?: true

Size: 827 Bytes

Versions: 18

Compression:

Stored size: 827 Bytes

Contents

require "logtail/context"
require "logtail/util"

module Logtail
  module Contexts
    # 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
      attr_reader :hostname, :pid

      def initialize(attributes)
        @hostname = attributes[:hostname]
        @pid = attributes[:pid]
      end

      # Builds a hash representation containing simple objects, suitable for serialization (JSON).
      def to_hash
        @to_hash ||= {
          system: Util::NonNilHashBuilder.build do |h|
            h.add(:hostname, hostname)
            h.add(:pid, pid)
          end
        }
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
logtail-ruby-0.1.3 lib/logtail/contexts/system.rb
logtail-0.1.13 lib/logtail/contexts/system.rb
logtail-0.1.12 lib/logtail/contexts/system.rb
logtail-0.1.11 lib/logtail/contexts/system.rb
logtail-0.1.10 lib/logtail/contexts/system.rb
logtail-0.1.9 lib/logtail/contexts/system.rb
logtail-0.1.8 lib/logtail/contexts/system.rb
logtail-0.1.7 lib/logtail/contexts/system.rb
logtail-0.1.6 lib/logtail/contexts/system.rb
logtail-0.1.5 lib/logtail/contexts/system.rb
logtail-0.1.4 lib/logtail/contexts/system.rb
logtail-0.1.3 lib/logtail/contexts/system.rb
logtail-0.1.2 lib/logtail/contexts/system.rb
logtail-0.1.1 lib/logtail/contexts/system.rb
logtail-0.1.0 lib/logtail/contexts/system.rb
logtail-ruby-0.1.2 lib/logtail/contexts/system.rb
logtail-ruby-0.1.1 lib/logtail/contexts/system.rb
logtail-ruby-0.1.0 lib/logtail/contexts/system.rb