rails_error_logger 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/README.md +37 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/bugsnag/rails_error_logger/bugsnag.rb +17 -0
- data/lib/rails_error_logger.rb +5 -0
- data/lib/rails_error_logger/logger.rb +21 -0
- data/lib/rails_error_logger/railtie.rb +12 -0
- data/lib/rails_error_logger/version.rb +3 -0
- data/rails_error_logger.gemspec +28 -0
- metadata +128 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4891aef8239745d5e3db82960fe1e6f71b181ebf
|
4
|
+
data.tar.gz: a8fa130516ae141a8d746aa8c9d6fc4505332266
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3f0868bff50f35ff1cfe81e949d23c7c316f9ddc1cb9561d1f06449007a58ee2cad283a9479832dc21aecd3d9b38b1d80cabc50fefc15015f2c80d68aa05b5bd
|
7
|
+
data.tar.gz: 7400725208feb2d4de0465c591ef15691cae585e20d4fd774ffd82362c8264eb6411b5e11030ab9e8eec4c9a147d6dc0c8fe87abe93c68a5da2c07ead157bb43
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# RailsErrorLogger
|
2
|
+
|
3
|
+
Rails の logger.error で Bugsnag.notify できる様にする gem。
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rails_error_logger'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install rails_error_logger
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
1. Fork it ( https://github.com/koshigoe/rails_error_logger/fork )
|
34
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
35
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
36
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
37
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rails_error_logger"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'bugsnag'
|
2
|
+
|
3
|
+
module RailsErrorLogger
|
4
|
+
class Bugsnag
|
5
|
+
def write(message)
|
6
|
+
if message[:options][:severity] >= Logger::ERROR
|
7
|
+
message[:options][:severity] = 'error'
|
8
|
+
elsif message[:options][:severity] >= Logger::WARN
|
9
|
+
message[:options][:severity] = 'warning'
|
10
|
+
else
|
11
|
+
message[:options][:severity] = 'info'
|
12
|
+
end
|
13
|
+
|
14
|
+
::Bugsnag.notify(message[:exception], message[:options])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'active_support/logger'
|
2
|
+
require 'bugsnag/rails_error_logger/bugsnag'
|
3
|
+
|
4
|
+
module RailsErrorLogger
|
5
|
+
class Logger < ActiveSupport::Logger
|
6
|
+
def initialize(*args)
|
7
|
+
@progname = nil
|
8
|
+
@level = ERROR
|
9
|
+
@default_formatter = proc do |severity, datetime, progname, msg|
|
10
|
+
{
|
11
|
+
exception: RuntimeError.new(msg),
|
12
|
+
options: {
|
13
|
+
severity: SEV_LABEL.index(severity)
|
14
|
+
}
|
15
|
+
}
|
16
|
+
end
|
17
|
+
@formatter = nil
|
18
|
+
@logdev = "RailsErrorLogger::#{args.first.to_s.camelize}".constantize.new
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require 'rails_error_logger/logger'
|
3
|
+
|
4
|
+
module RailsErrorLogger
|
5
|
+
class Railtie < Rails::Railtie
|
6
|
+
initializer :add_bugsnag_logger, before: :load_config_initializers do
|
7
|
+
error_logger = RailsErrorLogger::Logger.new(:bugsnag)
|
8
|
+
error_logger.level = Logger::WARN
|
9
|
+
Rails.logger.extend ActiveSupport::Logger.broadcast(error_logger)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rails_error_logger/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rails_error_logger"
|
8
|
+
spec.version = RailsErrorLogger::VERSION
|
9
|
+
spec.authors = ["koshigoe"]
|
10
|
+
spec.email = ["koshigoeb@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Add logger for error monitoring.}
|
13
|
+
spec.description = %q{Add logger for error monitoring.}
|
14
|
+
spec.homepage = "https://github.com/koshigoe/rails_error_logger"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
|
25
|
+
spec.add_runtime_dependency "railties"
|
26
|
+
spec.add_runtime_dependency "activesupport"
|
27
|
+
spec.add_runtime_dependency "bugsnag"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_error_logger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- koshigoe
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: railties
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bugsnag
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Add logger for error monitoring.
|
84
|
+
email:
|
85
|
+
- koshigoeb@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Gemfile
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/console
|
97
|
+
- bin/setup
|
98
|
+
- lib/bugsnag/rails_error_logger/bugsnag.rb
|
99
|
+
- lib/rails_error_logger.rb
|
100
|
+
- lib/rails_error_logger/logger.rb
|
101
|
+
- lib/rails_error_logger/railtie.rb
|
102
|
+
- lib/rails_error_logger/version.rb
|
103
|
+
- rails_error_logger.gemspec
|
104
|
+
homepage: https://github.com/koshigoe/rails_error_logger
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.4.5
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: Add logger for error monitoring.
|
128
|
+
test_files: []
|