whoops_logger 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -10,6 +10,10 @@ group :development do
10
10
  gem "rspec", "~> 2.6.0"
11
11
  gem "bundler", "~> 1.0.0"
12
12
  gem "jeweler", "~> 1.5.2"
13
- gem "ruby-debug"
13
+ if RUBY_VERSION =~ /1.8/
14
+ gem "ruby-debug"
15
+ else
16
+ gem "ruby-debug19"
17
+ end
14
18
  gem "fakeweb"
15
19
  end
@@ -1,134 +1,7 @@
1
1
  = Whoops Logger
2
-
3
2
  Use Whoops Logger to send log messages to a https://github.com/flyingmachine/whoops[Whoops] server.
4
3
 
5
- == Installation
6
-
7
- Add +whoops_logger+ to your Gemfile
8
-
9
- Add +WhoopsLogger.config.set(config_path)+ to your project, where +config_path+ is a path to a YAML file. The YAML file takes the following options:
10
-
11
- ----
12
- :host
13
- :http_open_timeout
14
- :http_read_timeout,
15
- :port
16
- :protocol
17
- :proxy_host,
18
- :proxy_pass
19
- :proxy_port
20
- :proxy_user
21
- :secure
22
- ----
23
-
24
- You can also use pass a Hash to +WhoopsLogger.config.set+ instead of a path to a YAML file.
25
-
26
- == Usage
27
-
28
- Whoops Logger sends Messages to Whoops. Messages are created with Strategies. Below is the basic strategy found in `lib/whoops_logger/basic.rb`:
29
-
30
- ----
31
- strategy = WhoopsLogger::Strategy.new("default::basic")
32
-
33
- strategy.add_message_builder(:use_basic_hash) do |message, raw_data|
34
- message.event_type = raw_data[:event_type]
35
- message.service = raw_data[:service]
36
- message.environment = raw_data[:environment]
37
- message.message = raw_data[:message]
38
- message.event_group_identifier = raw_data[:event_group_identifier]
39
- message.event_time = raw_data[:event_time] if raw_data[:event_time]
40
- message.details = raw_data[:details]
41
- end
42
- ----
43
-
44
- To use this strategy, you would call
45
-
46
- ----
47
- WhoopsLogger.log("default::basic", {
48
- :event_type => "your_event_type",
49
- :service => "your_service_name",
50
- :environment => "development",
51
- :message => "String to Show in Whoops Event List",
52
- :event_group_identifier => "String used to assign related events to a group",
53
- :event_time => "Defaults to now",
54
- :details => "A string, hash, or array of arbitrary data"
55
- })
56
- ----
57
-
58
- You can create as many strategies as you need. For example, in a Rails app, you could use a strategy for logging exceptions which occur during a controller action (in fact https://github.com/flyingmachine/whoops_rails_logger[there's a gem for that]). You could use a separate strategy for logging exceptions which occur during a background job. With controller actions, you care about params, sessions, and that data. That data isn't even present in background jobs, so it makes sense to use different strategies.
59
-
60
- === Message Builders
61
-
62
- Each strategy consists of one or more message builders. The message builders are called in the order in which they are defined.
63
-
64
- Internally, each Strategy stores its message builders in the array +message_builders+, and it's possible to modify that array directly if you want. For example, you might want to modify a Strategy provided by a library.
65
-
66
- The method +add_message_builder+ is provided for convenience. Below is an example of +add_message_builder+ taken from the https://github.com/flyingmachine/whoops_rails_logger[Whoops Rails Logger]:
67
-
68
- ----
69
- strategy.add_message_builder(:basic_details) do |message, raw_data|
70
- message.service = self.service
71
- message.environment = self.environment
72
- message.event_type = "exception"
73
- message.message = raw_data[:exception].message
74
- message.event_time = Time.now
75
- end
76
-
77
- strategy.add_message_builder(:details) do |message, raw_data|
78
- exception = raw_data[:exception]
79
- rack_env = raw_data[:rack_env]
80
-
81
- details = {}
82
- details[:backtrace] = exception.backtrace.collect{ |line|
83
- line.sub(/^#{ENV['GEM_HOME']}/, '$GEM_HOME').sub(/^#{Rails.root}/, '$Rails.root')
84
- }
85
-
86
- details[:http_host] = rack_env["HTTP_HOST"]
87
- details[:params] = rack_env["action_dispatch.request.parameters"]
88
- details[:query_string] = rack_env["QUERY_STRING"]
89
- details[:remote_addr] = rack_env["REMOTE_ADDR"]
90
- details[:request_method] = rack_env["REQUEST_METHOD"]
91
- details[:server_name] = rack_env["SERVER_NAME"]
92
- details[:session] = rack_env["rack.session"]
93
- details[:env] = ENV
94
- message.details = details
95
- end
96
-
97
- strategy.add_message_builder(:create_event_group_identifier) do |message, raw_data|
98
- identifier = "#{raw_data[:controller]}##{raw_data[:action]}"
99
- identifier << raw_data[:exception].backtrace.collect{|l| l.sub(Rails.root, "")}.join("\n")
100
- message.event_group_identifier = Digest::MD5.hexdigest(identifier)
101
- end
102
- ----
103
-
104
- There's a bit more about message builders in the WhoopsLogger::Strategy documentation.
105
-
106
- === Ignore Criteria
107
-
108
- Sometimes you want to ignore a message instead of sending it off to whoops. For example, you might not want to log "Record Not Found" exceptions in Rails. If any of the ignore criteria evaluate to true, then the message is ignored. Below is an example:
109
-
110
- ----
111
- strategy.add_ignore_criteria(:ignore_record_not_found) do |message|
112
- message.message == "Record Not Found"
113
- end
114
-
115
- strategy.add_ignore_criteria(:ignore_dev_environment) do |message|
116
- message.environment == "development"
117
- end
118
- ----
119
-
120
- == Contributing to whoops_logger
121
-
122
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
123
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
124
- * Fork the project
125
- * Start a feature/bugfix branch
126
- * Commit and push until you are happy with your contribution
127
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
128
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
129
-
130
- == Copyright
131
-
132
- Copyright (c) 2011 Daniel Higginbotham. See LICENSE.txt for
133
- further details.
4
+ Full documentation can be found at http://www.whoopsapp.com[the Whoops web site].
134
5
 
6
+ == License
7
+ This project uses MIT-LICENSE.
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ require 'jeweler'
13
13
  Jeweler::Tasks.new do |gem|
14
14
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
15
  gem.name = "whoops_logger"
16
- gem.homepage = "http://github.com/flyingmachine/whoops_logger"
16
+ gem.homepage = "http://www.whoopsapp.com"
17
17
  gem.license = "MIT"
18
18
  gem.summary = %Q{Handles basic notification responsibilities and allows creation of message creation strategies}
19
19
  gem.description = %Q{Handles basic notification responsibilities and allows creation of message creation strategies}
@@ -35,7 +35,9 @@ module WhoopsLogger
35
35
 
36
36
  # The password to use when logging into your proxy server (if using a proxy)
37
37
  attr_accessor :proxy_pass
38
-
38
+
39
+ attr_accessor :logger
40
+
39
41
  alias_method :secure?, :secure
40
42
 
41
43
  def initialize
@@ -5,17 +5,13 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{whoops_logger}
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Daniel Higginbotham"]
12
12
  s.date = %q{2011-07-31}
13
13
  s.description = %q{Handles basic notification responsibilities and allows creation of message creation strategies}
14
14
  s.email = %q{daniel@flyingmachinestudios.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.asciidoc"
18
- ]
19
15
  s.files = [
20
16
  ".document",
21
17
  ".rspec",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whoops_logger
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Higginbotham
@@ -19,10 +19,9 @@ date: 2011-07-31 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- prerelease: false
23
- type: :runtime
24
22
  name: json
25
- version_requirements: &id001 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
26
25
  none: false
27
26
  requirements:
28
27
  - - ">="
@@ -31,12 +30,12 @@ dependencies:
31
30
  segments:
32
31
  - 0
33
32
  version: "0"
34
- requirement: *id001
33
+ type: :runtime
34
+ version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
36
- prerelease: false
37
- type: :development
38
36
  name: rspec
39
- version_requirements: &id002 !ruby/object:Gem::Requirement
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
41
  - - ~>
@@ -47,12 +46,12 @@ dependencies:
47
46
  - 6
48
47
  - 0
49
48
  version: 2.6.0
50
- requirement: *id002
51
- - !ruby/object:Gem::Dependency
52
- prerelease: false
53
49
  type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
54
52
  name: bundler
55
- version_requirements: &id003 !ruby/object:Gem::Requirement
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
56
55
  none: false
57
56
  requirements:
58
57
  - - ~>
@@ -63,12 +62,12 @@ dependencies:
63
62
  - 0
64
63
  - 0
65
64
  version: 1.0.0
66
- requirement: *id003
67
- - !ruby/object:Gem::Dependency
68
- prerelease: false
69
65
  type: :development
66
+ version_requirements: *id003
67
+ - !ruby/object:Gem::Dependency
70
68
  name: jeweler
71
- version_requirements: &id004 !ruby/object:Gem::Requirement
69
+ prerelease: false
70
+ requirement: &id004 !ruby/object:Gem::Requirement
72
71
  none: false
73
72
  requirements:
74
73
  - - ~>
@@ -79,12 +78,12 @@ dependencies:
79
78
  - 5
80
79
  - 2
81
80
  version: 1.5.2
82
- requirement: *id004
83
- - !ruby/object:Gem::Dependency
84
- prerelease: false
85
81
  type: :development
82
+ version_requirements: *id004
83
+ - !ruby/object:Gem::Dependency
86
84
  name: ruby-debug
87
- version_requirements: &id005 !ruby/object:Gem::Requirement
85
+ prerelease: false
86
+ requirement: &id005 !ruby/object:Gem::Requirement
88
87
  none: false
89
88
  requirements:
90
89
  - - ">="
@@ -93,12 +92,12 @@ dependencies:
93
92
  segments:
94
93
  - 0
95
94
  version: "0"
96
- requirement: *id005
97
- - !ruby/object:Gem::Dependency
98
- prerelease: false
99
95
  type: :development
96
+ version_requirements: *id005
97
+ - !ruby/object:Gem::Dependency
100
98
  name: fakeweb
101
- version_requirements: &id006 !ruby/object:Gem::Requirement
99
+ prerelease: false
100
+ requirement: &id006 !ruby/object:Gem::Requirement
102
101
  none: false
103
102
  requirements:
104
103
  - - ">="
@@ -107,16 +106,16 @@ dependencies:
107
106
  segments:
108
107
  - 0
109
108
  version: "0"
110
- requirement: *id006
109
+ type: :development
110
+ version_requirements: *id006
111
111
  description: Handles basic notification responsibilities and allows creation of message creation strategies
112
112
  email: daniel@flyingmachinestudios.com
113
113
  executables: []
114
114
 
115
115
  extensions: []
116
116
 
117
- extra_rdoc_files:
118
- - LICENSE.txt
119
- - README.asciidoc
117
+ extra_rdoc_files: []
118
+
120
119
  files:
121
120
  - .document
122
121
  - .rspec