errplane 0.3.7 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/.gitignore +2 -1
  2. data/.rspec +2 -0
  3. data/.travis.yml +22 -0
  4. data/README.md +2 -10
  5. data/Rakefile +19 -31
  6. data/errplane.gemspec +5 -9
  7. data/gemfiles/Gemfile.rails-2.3.x +8 -0
  8. data/gemfiles/Gemfile.rails-2.3.x.lock +60 -0
  9. data/gemfiles/{rails_3.2.gemfile → Gemfile.rails-3.0.x} +2 -2
  10. data/gemfiles/Gemfile.rails-3.0.x.lock +82 -0
  11. data/gemfiles/{rails_3.1.gemfile → Gemfile.rails-3.1.x} +2 -1
  12. data/gemfiles/Gemfile.rails-3.1.x.lock +94 -0
  13. data/gemfiles/{rails_3.0.gemfile → Gemfile.rails-3.2.x} +2 -1
  14. data/gemfiles/Gemfile.rails-3.2.x.lock +92 -0
  15. data/lib/errplane.rb +15 -10
  16. data/lib/errplane/backtrace.rb +38 -0
  17. data/lib/errplane/black_box.rb +8 -5
  18. data/lib/errplane/capistrano.rb +0 -1
  19. data/lib/errplane/configuration.rb +30 -22
  20. data/lib/errplane/errplane_chef_handler.rb +2 -4
  21. data/lib/errplane/logger.rb +11 -0
  22. data/lib/errplane/rails/air_traffic_controller.rb +2 -1
  23. data/lib/errplane/rails/middleware/hijack_render_exception.rb +5 -2
  24. data/lib/errplane/railtie.rb +0 -9
  25. data/lib/errplane/transmitter.rb +19 -11
  26. data/lib/errplane/version.rb +1 -1
  27. data/lib/rails/generators/errplane/templates/initializer.rb +0 -3
  28. data/spec/app/rails2.rb +38 -0
  29. data/spec/app/{rails.rb → rails3.rb} +0 -3
  30. data/spec/integration/exceptions_spec.rb +27 -9
  31. data/spec/rails2/README +243 -0
  32. data/spec/rails2/Rakefile +10 -0
  33. data/spec/rails2/app/controllers/application_controller.rb +10 -0
  34. data/spec/rails2/app/controllers/widgets_controller.rb +5 -0
  35. data/spec/rails2/app/helpers/application_helper.rb +3 -0
  36. data/spec/rails2/app/helpers/widgets_helper.rb +1 -0
  37. data/spec/rails2/config/boot.rb +114 -0
  38. data/spec/rails2/config/database.yml +3 -0
  39. data/spec/rails2/config/environment.rb +33 -0
  40. data/spec/rails2/config/environments/development.rb +17 -0
  41. data/spec/rails2/config/environments/production.rb +28 -0
  42. data/spec/{internal/public/favicon.ico → rails2/config/environments/test.rb} +0 -0
  43. data/spec/rails2/config/initializers/backtrace_silencers.rb +7 -0
  44. data/spec/rails2/config/initializers/cookie_verification_secret.rb +7 -0
  45. data/spec/{internal → rails2}/config/initializers/errplane.rb +0 -0
  46. data/spec/rails2/config/initializers/inflections.rb +10 -0
  47. data/spec/rails2/config/initializers/mime_types.rb +5 -0
  48. data/spec/rails2/config/initializers/new_rails_defaults.rb +21 -0
  49. data/spec/rails2/config/initializers/session_store.rb +15 -0
  50. data/spec/rails2/config/locales/en.yml +5 -0
  51. data/spec/rails2/config/routes.rb +3 -0
  52. data/spec/rails2/lib/tasks/rspec.rake +144 -0
  53. data/spec/rails2/log/development.log +0 -0
  54. data/spec/rails2/log/production.log +0 -0
  55. data/spec/rails2/log/server.log +0 -0
  56. data/spec/rails2/log/test.log +785 -0
  57. data/spec/rails2/public/404.html +30 -0
  58. data/spec/rails2/public/422.html +30 -0
  59. data/spec/rails2/public/500.html +30 -0
  60. data/spec/rails2/public/favicon.ico +0 -0
  61. data/spec/rails2/public/images/rails.png +0 -0
  62. data/spec/rails2/public/index.html +275 -0
  63. data/spec/rails2/public/javascripts/application.js +2 -0
  64. data/spec/rails2/public/javascripts/controls.js +963 -0
  65. data/spec/rails2/public/javascripts/dragdrop.js +973 -0
  66. data/spec/rails2/public/javascripts/effects.js +1128 -0
  67. data/spec/rails2/public/javascripts/prototype.js +4320 -0
  68. data/spec/rails2/public/robots.txt +5 -0
  69. data/spec/rails2/script/about +4 -0
  70. data/spec/rails2/script/autospec +6 -0
  71. data/spec/rails2/script/console +3 -0
  72. data/spec/rails2/script/dbconsole +3 -0
  73. data/spec/rails2/script/destroy +3 -0
  74. data/spec/rails2/script/generate +3 -0
  75. data/spec/rails2/script/performance/benchmarker +3 -0
  76. data/spec/rails2/script/performance/profiler +3 -0
  77. data/spec/rails2/script/plugin +3 -0
  78. data/spec/rails2/script/runner +3 -0
  79. data/spec/rails2/script/server +3 -0
  80. data/spec/rails2/script/spec +10 -0
  81. data/spec/rails2/test/performance/browsing_test.rb +9 -0
  82. data/spec/rails2/test/test_helper.rb +38 -0
  83. data/spec/spec_helper.rb +27 -16
  84. data/spec/suite.sh +39 -0
  85. data/spec/unit/backtrace_spec.rb +62 -0
  86. data/spec/unit/black_box_spec.rb +3 -3
  87. data/spec/unit/configuration_spec.rb +29 -0
  88. data/spec/unit/errplane_spec.rb +24 -15
  89. data/specs.watchr +21 -0
  90. metadata +194 -90
  91. data/gemfiles/rails_2.3.gemfile +0 -6
  92. data/gemfiles/rails_2.3.gemfile.lock +0 -148
  93. data/gemfiles/rails_3.0.gemfile.lock +0 -148
  94. data/gemfiles/rails_3.1.gemfile.lock +0 -148
  95. data/gemfiles/rails_3.2.gemfile.lock +0 -121
  96. data/lib/errplane/rails/udp_logger.rb +0 -54
  97. data/lib/errplane/syslogproto.rb +0 -7
  98. data/lib/errplane/syslogproto/common.rb +0 -81
  99. data/lib/errplane/syslogproto/logger.rb +0 -24
  100. data/lib/errplane/syslogproto/packet.rb +0 -107
  101. data/lib/errplane/syslogproto/parser.rb +0 -51
  102. data/spec/internal/app/controllers/application_controller.rb +0 -2
  103. data/spec/internal/app/controllers/widgets_controller.rb +0 -9
  104. data/spec/internal/config/database.yml +0 -3
  105. data/spec/internal/config/routes.rb +0 -3
  106. data/spec/internal/db/combustion_test.sqlite +0 -0
  107. data/spec/internal/db/schema.rb +0 -3
  108. data/spec/internal/log/.gitignore +0 -1
@@ -1,54 +0,0 @@
1
- module Errplane
2
- class UdpLogger
3
- def initialize(port)
4
- @host = "syslogd.errplane.com"
5
- @port = port
6
-
7
- @syslog_p = SyslogProto::Packet.new
8
-
9
- local_hostname = (Socket.gethostname rescue `hostname`.chomp)
10
- local_hostname = 'localhost' if local_hostname.nil? || local_hostname.empty?
11
- @syslog_p.hostname = local_hostname
12
-
13
- @syslog_p.facility = 'user'
14
- @syslog_p.severity = 'notice'
15
- @udpsocket = UDPSocket.new
16
- puts "Setting up Errplane remote logger on port -#{@host}:#{@port}"
17
- end
18
-
19
- def write(message)
20
- message.split(/\r?\n/).each do |line|
21
- begin
22
- next if line =~ /^\s*$/
23
- pak = @syslog_p.dup
24
- pak.msg = line
25
- @udpsocket.send(pak.assemble, 0, @host, @port)
26
- rescue => e
27
- puts e
28
- puts e.backtrace
29
- #ignore errors
30
- end
31
- end
32
- end
33
-
34
- def close
35
- @udpsocket.close
36
- end
37
- end
38
- end
39
-
40
- begin
41
- if( Errplane.configuration.syslogd_port && Errplane.configuration.syslogd_port != "")
42
- require "uri"
43
- require 'socket'
44
- require 'errplane/syslogproto'
45
-
46
- logger = Logger.new(Errplane::UdpLogger.new( Errplane.configuration.syslogd_port.to_i))
47
- logger.level = Logger::INFO
48
-
49
- logger.error "TEST"
50
- Rails.logger = Rails.application.config.logger = ActionController::Base.logger = Rails.cache.logger = logger
51
- end
52
- rescue => e
53
- puts "Failed to setup remote logger for Errplane! -#{e}"
54
- end
@@ -1,7 +0,0 @@
1
- $:.unshift File.expand_path(File.dirname(File.expand_path(__FILE__)))
2
- require 'syslogproto/common'
3
- require 'syslogproto/packet'
4
- require 'syslogproto/logger'
5
- require 'syslogproto/parser'
6
-
7
- #THIS was forked from https://github.com/jakedouglas/syslog
@@ -1,81 +0,0 @@
1
- module SyslogProto
2
-
3
- # These hashes stolen from Syslog.pm
4
-
5
- FACILITIES = {
6
- 'kern' => 0,
7
- 'user' => 1,
8
- 'mail' => 2,
9
- 'daemon' => 3,
10
- 'auth' => 4,
11
- 'syslog' => 5,
12
- 'lpr' => 6,
13
- 'news' => 7,
14
- 'uucp' => 8,
15
- 'cron' => 9,
16
- 'authpriv' => 10,
17
- 'ftp' => 11,
18
- 'ntp' => 12,
19
- 'audit' => 13,
20
- 'alert' => 14,
21
- 'at' => 15,
22
- 'local0' => 16,
23
- 'local1' => 17,
24
- 'local2' => 18,
25
- 'local3' => 19,
26
- 'local4' => 20,
27
- 'local5' => 21,
28
- 'local6' => 22,
29
- 'local7' => 23
30
- }
31
-
32
- FACILITY_INDEX = {
33
- 0 => 'kern',
34
- 1 => 'user',
35
- 2 => 'mail',
36
- 3 => 'daemon',
37
- 4 => 'auth',
38
- 5 => 'syslog',
39
- 6 => 'lpr',
40
- 7 => 'news',
41
- 8 => 'uucp',
42
- 9 => 'cron',
43
- 10 => 'authpriv',
44
- 11 => 'ftp',
45
- 12 => 'ntp',
46
- 13 => 'audit',
47
- 14 => 'alert',
48
- 15 => 'at',
49
- 16 => 'local0',
50
- 17 => 'local1',
51
- 18 => 'local2',
52
- 19 => 'local3',
53
- 20 => 'local4',
54
- 21 => 'local5',
55
- 22 => 'local6',
56
- 23 => 'local7'
57
- }
58
-
59
- SEVERITIES = {
60
- 'emerg' => 0,
61
- 'alert' => 1,
62
- 'crit' => 2,
63
- 'err' => 3,
64
- 'warn' => 4,
65
- 'notice' => 5,
66
- 'info' => 6,
67
- 'debug' => 7
68
- }
69
-
70
- SEVERITY_INDEX = {
71
- 0 => 'emerg',
72
- 1 => 'alert',
73
- 2 => 'crit',
74
- 3 => 'err',
75
- 4 => 'warn',
76
- 5 => 'notice',
77
- 6 => 'info',
78
- 7 => 'debug'
79
- }
80
-
81
- end
@@ -1,24 +0,0 @@
1
- module SyslogProto
2
-
3
- class Logger
4
-
5
- def initialize(hostname, facility)
6
- @packet = Packet.new
7
- @packet.hostname = hostname
8
- @packet.facility = facility
9
- end
10
-
11
- SEVERITIES.each do |k,v|
12
- define_method(k) do |*args|
13
- msg = args.shift
14
- raise ArgumentError.new "MSG may not be omitted" unless msg and msg.length > 0
15
- p = @packet.dup
16
- p.severity = k
17
- p.msg = msg
18
- p.assemble
19
- end
20
- end
21
-
22
- end
23
-
24
- end
@@ -1,107 +0,0 @@
1
- module SyslogProto
2
-
3
- class Packet
4
-
5
- attr_reader :facility, :severity, :hostname
6
- attr_accessor :time, :msg
7
-
8
- def to_s
9
- assemble
10
- end
11
-
12
- def assemble
13
- unless @hostname and @facility and @severity
14
- return "I AM A JUNK PACKET CUZ MY USER DIDNT SET ME"
15
- end
16
- data = "<#{pri}>#{generate_timestamp} #{@hostname} #{@msg}"
17
- while data.bytesize > 1024
18
- data = data[0..(data.length-2)]
19
- end
20
- data
21
- end
22
-
23
- def facility=(f)
24
- if f.is_a? Integer
25
- if (0..23).include?(f)
26
- @facility = f
27
- else
28
- raise ArgumentError.new "Facility must be within 0-23"
29
- end
30
- elsif f.is_a? String
31
- if facility = FACILITIES[f]
32
- @facility = facility
33
- else
34
- raise ArgumentError.new "'#{f}' is not a designated facility"
35
- end
36
- else
37
- raise ArgumentError.new "Facility must be a designated number or string"
38
- end
39
- end
40
-
41
- def severity=(s)
42
- if s.is_a? Integer
43
- if (0..7).include?(s)
44
- @severity = s
45
- else
46
- raise ArgumentError.new "Severity must be within 0-7"
47
- end
48
- elsif s.is_a? String
49
- if severity = SEVERITIES[s]
50
- @severity = severity
51
- else
52
- raise ArgumentError.new "'#{s}' is not a designated severity"
53
- end
54
- else
55
- raise ArgumentError.new "Severity must be a designated number or string"
56
- end
57
- end
58
-
59
- def hostname=(h)
60
- unless h and h.is_a? String and h.length > 0
61
- raise ArgumentError.new("Hostname may not be omitted")
62
- end
63
- if h =~ /\s/
64
- raise ArgumentError.new("Hostname may not contain spaces")
65
- end
66
- if h =~ /[^\x21-\x7E]/
67
- raise ArgumentError.new("Hostname may only contain ASCII characters 33-126")
68
- end
69
- @hostname = h
70
- end
71
-
72
- def facility_name
73
- FACILITY_INDEX[@facility]
74
- end
75
-
76
- def severity_name
77
- SEVERITY_INDEX[@severity]
78
- end
79
-
80
- def pri
81
- (@facility * 8) + @severity
82
- end
83
-
84
- def pri=(p)
85
- unless p.is_a? Integer and (0..191).include?(p)
86
- raise ArgumentError.new "PRI must be a number between 0 and 191"
87
- end
88
- @facility = p / 8
89
- @severity = p - (@facility * 8)
90
- end
91
-
92
- def generate_timestamp
93
- time = @time || Time.now
94
- # The timestamp format requires that a day with fewer than 2 digits have
95
- # what would normally be a preceding zero, be instead an extra space.
96
- day = time.strftime("%d")
97
- day = day.sub(/^0/, ' ') if day =~ /^0\d/
98
- time.strftime("%b #{day} %H:%M:%S")
99
- end
100
-
101
- SEVERITIES.each do |k,v|
102
- define_method("#{k}?") {SEVERITIES[k] == @severity}
103
- end
104
-
105
- end
106
-
107
- end
@@ -1,51 +0,0 @@
1
- require 'time'
2
-
3
- module SyslogProto
4
-
5
- def self.parse(msg, origin=nil)
6
- packet = Packet.new
7
- original_msg = msg.dup
8
- pri = parse_pri(msg)
9
- if pri and (pri = pri.to_i).is_a? Integer and (0..191).include?(pri)
10
- packet.pri = pri
11
- else
12
- # If there isn't a valid PRI, treat the entire message as content
13
- packet.pri = 13
14
- packet.time = Time.now
15
- packet.hostname = origin || 'unknown'
16
- packet.msg = original_msg
17
- return packet
18
- end
19
- time = parse_time(msg)
20
- if time
21
- packet.time = Time.parse(time)
22
- else
23
- packet.time = Time.now
24
- end
25
- hostname = parse_hostname(msg)
26
- packet.hostname = hostname || origin
27
- packet.msg = msg
28
- packet
29
- end
30
-
31
- private
32
-
33
- def self.parse_pri(msg)
34
- pri = msg.slice!(/<(\d\d?\d?)>/)
35
- pri = pri.slice(/\d\d?\d?/) if pri
36
- if !pri or (pri =~ /^0/ and pri !~ /^0$/)
37
- return nil
38
- else
39
- return pri
40
- end
41
- end
42
-
43
- def self.parse_time(msg)
44
- msg.slice!(/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\s|[1-9])\d\s\d\d:\d\d:\d\d\s/)
45
- end
46
-
47
- def self.parse_hostname(msg)
48
- msg.slice!(/^[\x21-\x7E]+\s/).rstrip
49
- end
50
-
51
- end
@@ -1,2 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- end
@@ -1,9 +0,0 @@
1
- class WidgetsController < ApplicationController
2
- def index
3
- render :nothing => true
4
- end
5
-
6
- def new
7
- return 1/0
8
- end
9
- end
@@ -1,3 +0,0 @@
1
- test:
2
- adapter: sqlite3
3
- database: db/combustion_test.sqlite
@@ -1,3 +0,0 @@
1
- Rails.application.routes.draw do
2
- resources :widgets
3
- end
@@ -1,3 +0,0 @@
1
- ActiveRecord::Schema.define do
2
- #
3
- end
@@ -1 +0,0 @@
1
- *.log