exception-track 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/app/controllers/exception_track/logs_controller.rb +8 -6
- data/app/models/exception_track/log.rb +3 -1
- data/app/views/layouts/exception-track/application.html.erb +2 -2
- data/config/initializers/exception-track.rb +2 -0
- data/config/routes.rb +3 -1
- data/lib/exception-track.rb +10 -8
- data/lib/exception-track/configuration.rb +2 -0
- data/lib/exception-track/engine.rb +2 -0
- data/lib/exception-track/version.rb +3 -1
- data/lib/exception_notifier/exception_track_notifier.rb +22 -16
- data/lib/generators/exception_track/install_generator.rb +6 -4
- metadata +22 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2b5c7af8686be4792dcdc94ea552066bdecc1b4ba8aa014953cf795c223cda60
|
4
|
+
data.tar.gz: 56be676ea886fb6d6b585b4c3be72a8c036aead153fa9c795664ab4a1a708621
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42650b9bec639542c1261d817d25025b052f2e98ba5921112ea3a94c5752bcecf990db6f3078a85e981d45d38b19f27a379f9f210b20a175874bb7cdc11d2649
|
7
|
+
data.tar.gz: b2f5f412eb1395b7d6a5a63aaf5aa53d1fdff04256239e987bd6beb7f20ed99b45fdbd9242e76cdd27f4947b8ed98344b53cab98f294a4c956425503e31d114c
|
@@ -1,24 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ExceptionTrack
|
2
4
|
class LogsController < ActionController::Base
|
3
|
-
layout
|
4
|
-
before_action :set_log, only: [
|
5
|
+
layout "exception-track/application"
|
6
|
+
before_action :set_log, only: %i[show destroy]
|
5
7
|
|
6
8
|
# GET /exception_logs
|
7
9
|
def index
|
8
|
-
@logs = Log.order(
|
10
|
+
@logs = Log.order("id desc").page(params[:page]).per(15)
|
9
11
|
end
|
10
12
|
|
11
13
|
# GET /exception_logs/1
|
12
|
-
def show
|
13
|
-
end
|
14
|
+
def show; end
|
14
15
|
|
15
16
|
# DELETE /exception_logs/all
|
16
17
|
def all
|
17
18
|
Log.delete_all
|
18
|
-
redirect_to logs_url, notice:
|
19
|
+
redirect_to logs_url, notice: "Logs was successfully destroyed."
|
19
20
|
end
|
20
21
|
|
21
22
|
private
|
23
|
+
|
22
24
|
# Use callbacks to share common setup or constraints between actions.
|
23
25
|
def set_log
|
24
26
|
@log = Log.find(params[:id])
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
3
|
<head>
|
4
|
-
<title>Exception
|
5
|
-
<%= stylesheet_link_tag
|
4
|
+
<title>Exception Track</title>
|
5
|
+
<%= stylesheet_link_tag "exception-track/application", media: "all" %>
|
6
6
|
<%= csrf_meta_tags %>
|
7
7
|
</head>
|
8
8
|
<body>
|
data/config/routes.rb
CHANGED
data/lib/exception-track.rb
CHANGED
@@ -1,19 +1,21 @@
|
|
1
|
-
|
2
|
-
require 'exception-track/configuration'
|
3
|
-
require 'exception-track/engine'
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
3
|
+
require "exception-track/version"
|
4
|
+
require "exception-track/configuration"
|
5
|
+
require "exception-track/engine"
|
8
6
|
|
9
|
-
require
|
7
|
+
require "exception_notification"
|
8
|
+
require "exception_notification/rails"
|
9
|
+
require "exception_notifier/exception_track_notifier"
|
10
|
+
|
11
|
+
require "kaminari"
|
10
12
|
|
11
13
|
module ExceptionTrack
|
12
14
|
class << self
|
13
15
|
def config
|
14
16
|
return @config if defined?(@config)
|
15
17
|
@config = Configuration.new
|
16
|
-
@config.environments = %i
|
18
|
+
@config.environments = %i[development production]
|
17
19
|
@config
|
18
20
|
end
|
19
21
|
|
@@ -1,41 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# 异常通知
|
2
4
|
module ExceptionNotifier
|
3
5
|
class ExceptionTrackNotifier
|
4
|
-
def initialize(_options)
|
5
|
-
end
|
6
|
+
def initialize(_options); end
|
6
7
|
|
7
8
|
def call(exception, _options = {})
|
9
|
+
return unless ExceptionTrack.config.enabled_env?(Rails.env)
|
10
|
+
|
8
11
|
# send the notification
|
9
12
|
@title = exception.message
|
10
13
|
messages = []
|
11
|
-
messages << exception.inspect
|
12
|
-
messages << "\n"
|
13
|
-
messages << "--------------------------------------------------"
|
14
14
|
messages << headers_for_env(_options[:env])
|
15
|
+
messages << ""
|
15
16
|
messages << "--------------------------------------------------"
|
17
|
+
messages << ""
|
18
|
+
messages << exception.inspect
|
16
19
|
unless exception.backtrace.blank?
|
17
20
|
messages << "\n"
|
18
21
|
messages << exception.backtrace
|
19
22
|
end
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
ExceptionTrack::Log.create(title: @title, body: messages.join("\n"))
|
24
|
-
end
|
24
|
+
Rails.logger.silence do
|
25
|
+
ExceptionTrack::Log.create(title: @title, body: messages.join("\n"))
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
29
|
# Log Request headers from Rack env
|
29
30
|
def headers_for_env(env)
|
30
|
-
return
|
31
|
+
return "" if env.blank?
|
32
|
+
|
33
|
+
parameters = env["action_dispatch.request.parameters"] || {}
|
31
34
|
|
32
35
|
headers = []
|
33
|
-
headers << "Method:
|
34
|
-
headers << "URL:
|
35
|
-
headers << "
|
36
|
-
headers << "
|
37
|
-
headers << "
|
38
|
-
headers << "
|
36
|
+
headers << "Method: #{env['REQUEST_METHOD']}"
|
37
|
+
headers << "URL: #{env['REQUEST_URI']}"
|
38
|
+
headers << "Controller: #{parameters['controller']}##{parameters['action']}"
|
39
|
+
headers << "RequestId: #{env['action_dispatch.request_id']}"
|
40
|
+
headers << "User-Agent: #{env['HTTP_USER_AGENT']}"
|
41
|
+
headers << "Remote IP: #{env['REMOTE_ADDR']}"
|
42
|
+
headers << "Language: #{env['HTTP_ACCEPT_LANGUAGE']}"
|
43
|
+
headers << "Server: #{Socket.gethostname}"
|
44
|
+
headers << "Process: #{$PROCESS_ID}"
|
39
45
|
|
40
46
|
headers.join("\n")
|
41
47
|
end
|
@@ -1,16 +1,18 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators"
|
2
4
|
module ExceptionTrack
|
3
5
|
module Generators
|
4
6
|
class InstallGenerator < Rails::Generators::Base
|
5
7
|
desc "Create ExceptionTrack's base files"
|
6
|
-
source_root File.expand_path(
|
8
|
+
source_root File.expand_path("../../..", __dir__)
|
7
9
|
|
8
10
|
def add_initializer
|
9
|
-
template
|
11
|
+
template "config/initializers/exception-track.rb", "config/initializers/exception-track.rb"
|
10
12
|
end
|
11
13
|
|
12
14
|
def add_migrations
|
13
|
-
exec(
|
15
|
+
exec("rake exception_track:install:migrations")
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
metadata
CHANGED
@@ -1,63 +1,63 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exception-track
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: exception_notification
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '4.0'
|
20
|
-
- - "<"
|
17
|
+
- - "~>"
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
19
|
+
version: '4'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '4.0'
|
30
|
-
- - "<"
|
24
|
+
- - "~>"
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
26
|
+
version: '4'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
28
|
+
name: kaminari
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
|
-
- - "
|
31
|
+
- - ">="
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
33
|
+
version: '0.15'
|
40
34
|
type: :runtime
|
41
35
|
prerelease: false
|
42
36
|
version_requirements: !ruby/object:Gem::Requirement
|
43
37
|
requirements:
|
44
|
-
- - "
|
38
|
+
- - ">="
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
40
|
+
version: '0.15'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
42
|
+
name: rails
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
44
|
requirements:
|
51
45
|
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0
|
47
|
+
version: '4.0'
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '6'
|
54
51
|
type: :runtime
|
55
52
|
prerelease: false
|
56
53
|
version_requirements: !ruby/object:Gem::Requirement
|
57
54
|
requirements:
|
58
55
|
- - ">="
|
59
56
|
- !ruby/object:Gem::Version
|
60
|
-
version: '0
|
57
|
+
version: '4.0'
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '6'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: mysql2
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.6
|
121
|
+
rubygems_version: 2.7.6
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: Tracking exceptions for Rails application store them in database.
|