Class: CrashLog::SystemInformation
- Inherits:
-
Object
- Object
- CrashLog::SystemInformation
- Defined in:
- lib/crash_log/system_information.rb
Class Method Summary collapse
- .application_root ⇒ Object
- .environment ⇒ Object
- .hostname ⇒ Object
- .libraries_loaded ⇒ Object
- .platform ⇒ Object
- .ruby_version ⇒ Object
- .stage ⇒ Object
- .to_hash ⇒ Object
- .username ⇒ Object
Class Method Details
.application_root ⇒ Object
71 72 73 |
# File 'lib/crash_log/system_information.rb', line 71 def application_root CrashLog.configuration.root end |
.environment ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/crash_log/system_information.rb', line 35 def environment if ENV.respond_to?(:to_hash) env = ENV.to_hash.reject do |k, v| (k =~ /^HTTP_/) end unless CrashLog.configuration.environment_filters.empty? env.each do |k, v| if CrashLog.configuration.environment_filters.any? { |f| f.is_a?(Regexp) ? f =~ k.to_s : f.to_s == k.to_s } env[k] = '[FILTERED]' end end end env else {} end rescue {} end |
.hostname ⇒ Object
18 19 20 21 22 23 |
# File 'lib/crash_log/system_information.rb', line 18 def hostname require 'socket' unless defined?(Socket) Socket.gethostname rescue 'UNKNOWN' end |
.libraries_loaded ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/crash_log/system_information.rb', line 59 def libraries_loaded Hash[*Gem.loaded_specs.map {|name, gem_specification| [name, gem_specification.version.to_s] }.flatten] rescue {} end |
.platform ⇒ Object
67 68 69 |
# File 'lib/crash_log/system_information.rb', line 67 def platform RUBY_PLATFORM rescue '????' end |
.ruby_version ⇒ Object
25 26 27 |
# File 'lib/crash_log/system_information.rb', line 25 def ruby_version "#{RUBY_VERSION rescue '?.?.?'}-p#{RUBY_PATCHLEVEL rescue '???'} #{RUBY_RELEASE_DATE rescue '????-??-??'} #{RUBY_PLATFORM rescue '????'}" end |
.stage ⇒ Object
75 76 77 |
# File 'lib/crash_log/system_information.rb', line 75 def stage CrashLog.configuration.stage end |
.to_hash ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/crash_log/system_information.rb', line 5 def to_hash { :hostname => hostname, :ruby_version => ruby_version, :username => username, :environment => environment, :libraries_loaded => libraries_loaded, :platform => platform, :application_root => application_root, :stage => stage } end |
.username ⇒ Object
29 30 31 32 33 |
# File 'lib/crash_log/system_information.rb', line 29 def username ENV['LOGNAME'] || ENV['USER'] || ENV['USERNAME'] || ENV['APACHE_RUN_USER'] || 'UNKNOWN' rescue nil end |