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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c875c0aaf1fbe81d8dbb2fa04a2858ae29c8e8a4
4
- data.tar.gz: 928b5e9c267c400555e088237f473f1fc5125dcf
2
+ SHA256:
3
+ metadata.gz: 2b5c7af8686be4792dcdc94ea552066bdecc1b4ba8aa014953cf795c223cda60
4
+ data.tar.gz: 56be676ea886fb6d6b585b4c3be72a8c036aead153fa9c795664ab4a1a708621
5
5
  SHA512:
6
- metadata.gz: 85a430edb293dddcd70fe5a07d2fac50626a4779605187de460079c786699c837ff87831c8fddba39c9b6d4486dd6d8d666f962ec029b29f7db1c5b6d395715b
7
- data.tar.gz: '09e224807ccd04215280b76c663e704f8cd81e9f29bfe76fd586177fe4e1a0cb723306f956ae737b9145931c341b4d34252bcbc1e14d4cf3eacf1e725bb85e50'
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 'exception-track/application'
4
- before_action :set_log, only: [:show, :destroy]
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('id desc').page(params[:page]).per(15)
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: 'Logs was successfully destroyed.'
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,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ExceptionTrack
2
4
  class Log < ActiveRecord::Base
3
- self.table_name = 'exception_tracks'
5
+ self.table_name = "exception_tracks"
4
6
  end
5
7
  end
@@ -1,8 +1,8 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>Exception track</title>
5
- <%= stylesheet_link_tag "exception-track/application", media: "all" %>
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>
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # require 'exception_notification/sidekiq'
2
4
 
3
5
  ExceptionTrack.configure do
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ExceptionTrack::Engine.routes.draw do
2
- resources :logs, path: '' do
4
+ resources :logs, path: "" do
3
5
  collection do
4
6
  delete :all
5
7
  end
@@ -1,19 +1,21 @@
1
- require 'exception-track/version'
2
- require 'exception-track/configuration'
3
- require 'exception-track/engine'
1
+ # frozen_string_literal: true
4
2
 
5
- require 'exception_notification'
6
- require 'exception_notification/rails'
7
- require 'exception_notifier/exception_track_notifier'
3
+ require "exception-track/version"
4
+ require "exception-track/configuration"
5
+ require "exception-track/engine"
8
6
 
9
- require 'kaminari'
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(development production)
18
+ @config.environments = %i[development production]
17
19
  @config
18
20
  end
19
21
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ExceptionTrack
2
4
  class Configuration
3
5
  # environments for store Exception log in to database.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ExceptionTrack
2
4
  class Engine < ::Rails::Engine
3
5
  isolate_namespace ExceptionTrack
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ExceptionTrack
2
- VERSION = '0.2.0'
4
+ VERSION = "0.3.0"
3
5
  end
@@ -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
- if ExceptionTrack.config.enabled_env?(Rails.env)
22
- Rails.logger.silence do
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 '' if env.blank?
31
+ return "" if env.blank?
32
+
33
+ parameters = env["action_dispatch.request.parameters"] || {}
31
34
 
32
35
  headers = []
33
- headers << "Method: #{env['REQUEST_METHOD']}"
34
- headers << "URL: #{env['rack.url_scheme']}://#{env['HTTP_HOST']}#{env['REQUEST_URI']}"
35
- headers << "User-Agent: #{env['HTTP_USER_AGENT']}"
36
- headers << "Language: #{env['HTTP_ACCEPT_LANGUAGE']}"
37
- headers << "Server: #{Socket.gethostname}"
38
- headers << "Process: #{$$}"
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
- require 'rails/generators'
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('../../../../', __FILE__)
8
+ source_root File.expand_path("../../..", __dir__)
7
9
 
8
10
  def add_initializer
9
- template 'config/initializers/exception-track.rb', 'config/initializers/exception-track.rb'
11
+ template "config/initializers/exception-track.rb", "config/initializers/exception-track.rb"
10
12
  end
11
13
 
12
14
  def add_migrations
13
- exec('rake exception_track:install:migrations')
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.2.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: 2017-02-21 00:00:00.000000000 Z
11
+ date: 2018-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
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: '5.2'
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: '5.2'
26
+ version: '4'
33
27
  - !ruby/object:Gem::Dependency
34
- name: exception_notification
28
+ name: kaminari
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
- - - "~>"
31
+ - - ">="
38
32
  - !ruby/object:Gem::Version
39
- version: '4'
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: '4'
40
+ version: '0.15'
47
41
  - !ruby/object:Gem::Dependency
48
- name: kaminari
42
+ name: rails
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
45
  - - ">="
52
46
  - !ruby/object:Gem::Version
53
- version: '0.15'
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.15'
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.8
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.