hickory 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +56 -1
- data/Rakefile +6 -6
- data/bin/console +3 -3
- data/hickory.gemspec +4 -0
- data/lib/hickory.rb +2 -60
- data/lib/hickory/formatters/json.rb +14 -8
- data/lib/hickory/formatters/simple.rb +9 -2
- data/lib/hickory/log_subscribers/action_controller.rb +1 -1
- data/lib/hickory/logger.rb +12 -3
- data/lib/hickory/rails.rb +55 -0
- data/lib/hickory/rails/railtie.rb +15 -0
- data/lib/hickory/version.rb +1 -1
- metadata +47 -7
- data/lib/hickory/ext/rails/rack/logger.rb +0 -21
- data/lib/hickory/log_subscribers/base.rb +0 -68
- data/lib/hickory/railtie.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9d315687d17e63b704dc7748ffad0ca866d5d224c42b2469003faff0061881af
|
4
|
+
data.tar.gz: 63fd0fb477d88a8b853819daa412b4c6440692f34b2de7174d2e80867144d840
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d025b8a858179df3aa938580e1cb9b07daabc7346b029a821f8fae183a4ec093660cf28b688a692c91616c811a97dbda99cba5cfde2045be196781cf8f96951b
|
7
|
+
data.tar.gz: 687f88ddf0731a3974bfc2592e4ff802fca7415eab8f48167e578b829e98f5bff9b2e73938f145146d4ac0bd812a54a6ecab77b5c5668da7fcb389699b73b891
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,21 +2,76 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
hickory (0.1.1)
|
5
|
+
activesupport (>= 5.1)
|
6
|
+
railties (>= 5.1)
|
5
7
|
|
6
8
|
GEM
|
7
9
|
remote: https://rubygems.org/
|
8
10
|
specs:
|
11
|
+
actionpack (6.0.0)
|
12
|
+
actionview (= 6.0.0)
|
13
|
+
activesupport (= 6.0.0)
|
14
|
+
rack (~> 2.0)
|
15
|
+
rack-test (>= 0.6.3)
|
16
|
+
rails-dom-testing (~> 2.0)
|
17
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
18
|
+
actionview (6.0.0)
|
19
|
+
activesupport (= 6.0.0)
|
20
|
+
builder (~> 3.1)
|
21
|
+
erubi (~> 1.4)
|
22
|
+
rails-dom-testing (~> 2.0)
|
23
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
24
|
+
activesupport (6.0.0)
|
25
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
26
|
+
i18n (>= 0.7, < 2)
|
27
|
+
minitest (~> 5.1)
|
28
|
+
tzinfo (~> 1.1)
|
29
|
+
zeitwerk (~> 2.1, >= 2.1.8)
|
30
|
+
builder (3.2.3)
|
31
|
+
byebug (11.0.1)
|
32
|
+
concurrent-ruby (1.1.5)
|
33
|
+
crass (1.0.4)
|
34
|
+
erubi (1.8.0)
|
35
|
+
i18n (1.6.0)
|
36
|
+
concurrent-ruby (~> 1.0)
|
37
|
+
loofah (2.2.3)
|
38
|
+
crass (~> 1.0.2)
|
39
|
+
nokogiri (>= 1.5.9)
|
40
|
+
method_source (0.9.2)
|
41
|
+
mini_portile2 (2.4.0)
|
9
42
|
minitest (5.11.3)
|
43
|
+
nokogiri (1.10.4)
|
44
|
+
mini_portile2 (~> 2.4.0)
|
45
|
+
rack (2.0.7)
|
46
|
+
rack-test (1.1.0)
|
47
|
+
rack (>= 1.0, < 3)
|
48
|
+
rails-dom-testing (2.0.3)
|
49
|
+
activesupport (>= 4.2.0)
|
50
|
+
nokogiri (>= 1.6)
|
51
|
+
rails-html-sanitizer (1.2.0)
|
52
|
+
loofah (~> 2.2, >= 2.2.2)
|
53
|
+
railties (6.0.0)
|
54
|
+
actionpack (= 6.0.0)
|
55
|
+
activesupport (= 6.0.0)
|
56
|
+
method_source
|
57
|
+
rake (>= 0.8.7)
|
58
|
+
thor (>= 0.20.3, < 2.0)
|
10
59
|
rake (10.5.0)
|
60
|
+
thor (0.20.3)
|
61
|
+
thread_safe (0.3.6)
|
62
|
+
tzinfo (1.2.5)
|
63
|
+
thread_safe (~> 0.1)
|
64
|
+
zeitwerk (2.1.9)
|
11
65
|
|
12
66
|
PLATFORMS
|
13
67
|
ruby
|
14
68
|
|
15
69
|
DEPENDENCIES
|
16
70
|
bundler (~> 1.16)
|
71
|
+
byebug (~> 11.0, >= 11.0.1)
|
17
72
|
hickory!
|
18
73
|
minitest (~> 5.0)
|
19
74
|
rake (~> 10.0)
|
20
75
|
|
21
76
|
BUNDLED WITH
|
22
|
-
1.
|
77
|
+
1.17.2
|
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
3
|
|
4
4
|
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs <<
|
6
|
-
t.libs <<
|
7
|
-
t.test_files = FileList[
|
5
|
+
t.libs << 'test'
|
6
|
+
t.libs << 'lib'
|
7
|
+
t.test_files = FileList['test/**/*_test.rb']
|
8
8
|
end
|
9
9
|
|
10
|
-
task :
|
10
|
+
task default: :test
|
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'hickory'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "hickory"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start(__FILE__)
|
data/hickory.gemspec
CHANGED
@@ -19,7 +19,11 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
|
+
spec.add_runtime_dependency 'activesupport', '>= 5.1'
|
23
|
+
spec.add_runtime_dependency 'railties', '>= 5.1'
|
24
|
+
|
22
25
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
23
26
|
spec.add_development_dependency 'rake', '~> 10.0'
|
24
27
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
28
|
+
spec.add_development_dependency 'mocha', '~> 1.9.0'
|
25
29
|
end
|
data/lib/hickory.rb
CHANGED
@@ -1,64 +1,6 @@
|
|
1
1
|
require 'hickory/logger'
|
2
|
+
require 'hickory/rails' if defined? ::Rails
|
2
3
|
require 'hickory/version'
|
3
4
|
|
4
5
|
module Hickory
|
5
|
-
|
6
|
-
|
7
|
-
def initialize_canonical_logs(app)
|
8
|
-
require 'hickory/ext/rails/rack/logger'
|
9
|
-
|
10
|
-
self.application = app
|
11
|
-
Hickory.ignore_if = config.ignore_if
|
12
|
-
|
13
|
-
Hickory.remove_existing_log_subscriptions
|
14
|
-
Hickory::LogSubscribers::ActionController.attach_to :action_controller
|
15
|
-
Hickory::LogSubscribers::ActionMailer.attach_to :action_mailer
|
16
|
-
Hickory::LogSubscribers::ActiveJob.attach_to :active_job
|
17
|
-
end
|
18
|
-
|
19
|
-
def application
|
20
|
-
@@application
|
21
|
-
end
|
22
|
-
|
23
|
-
def application=(app)
|
24
|
-
@@application = app
|
25
|
-
end
|
26
|
-
|
27
|
-
def ignore_if
|
28
|
-
@@ignore_if
|
29
|
-
end
|
30
|
-
|
31
|
-
def ignore_if=(check)
|
32
|
-
@@ignore_if = check
|
33
|
-
end
|
34
|
-
|
35
|
-
def config
|
36
|
-
application.config.hickory
|
37
|
-
end
|
38
|
-
|
39
|
-
def remove_existing_log_subscriptions
|
40
|
-
ActiveSupport::LogSubscriber.log_subscribers.each do |subscriber|
|
41
|
-
case subscriber
|
42
|
-
when ActionView::LogSubscriber
|
43
|
-
unsubscribe(:action_view, subscriber)
|
44
|
-
when ActionController::LogSubscriber
|
45
|
-
unsubscribe(:action_controller, subscriber)
|
46
|
-
when ActionMailer::LogSubscriber
|
47
|
-
unsubscribe(:action_mailer, subscriber)
|
48
|
-
when ActiveJob::Logging::LogSubscriber
|
49
|
-
unsubscribe(:active_job, subscriber)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def unsubscribe(component, subscriber)
|
55
|
-
events = subscriber.public_methods(false).reject { |method| method.to_s == 'call' }
|
56
|
-
events.each do |event|
|
57
|
-
ActiveSupport::Notifications.notifier.listeners_for("#{event}.#{component}").each do |listener|
|
58
|
-
if listener.instance_variable_get('@delegate') == subscriber
|
59
|
-
ActiveSupport::Notifications.unsubscribe listener
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
6
|
+
end
|
@@ -1,25 +1,31 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
require 'active_support/json'
|
4
|
+
require 'active_support/tagged_logging'
|
5
|
+
|
1
6
|
module Hickory
|
2
7
|
module Formatters
|
3
8
|
class JSON < ::Logger::Formatter
|
9
|
+
include ActiveSupport::TaggedLogging::Formatter
|
10
|
+
|
4
11
|
def initialize(options = {})
|
5
|
-
@
|
12
|
+
@key_mapping = Hash.new.tap { |mapping|
|
6
13
|
mapping[:message] = options.fetch(:message_key, :message)
|
7
14
|
mapping[:severity] = options.fetch(:severity_key, :level)
|
8
15
|
mapping[:timestamp] = options.fetch(:timestamp_key, :timestamp)
|
9
|
-
mapping[:env] = options.fetch(:env_key, :env)
|
10
16
|
}
|
11
17
|
end
|
12
18
|
|
13
19
|
def call(severity, time, progname, msg)
|
14
20
|
line = msg.tap { |message|
|
15
|
-
message[@
|
16
|
-
message[@
|
17
|
-
message[@
|
18
|
-
message[
|
19
|
-
message[:
|
21
|
+
message[@key_mapping[:message]] = msg.delete(:message) unless @key_mapping[:message] == :message
|
22
|
+
message[@key_mapping[:timestamp]] = time
|
23
|
+
message[@key_mapping[:severity]] = severity
|
24
|
+
message[:progname] = progname unless progname.nil?
|
25
|
+
message[:tags] = current_tags unless current_tags.empty?
|
20
26
|
}
|
21
27
|
|
22
|
-
line.to_json
|
28
|
+
"#{line.to_json}\n"
|
23
29
|
end
|
24
30
|
end
|
25
31
|
end
|
@@ -1,11 +1,18 @@
|
|
1
|
+
require 'active_support/tagged_logging'
|
2
|
+
|
1
3
|
module Hickory
|
2
4
|
module Formatters
|
3
5
|
class Simple < ::Logger::Formatter
|
6
|
+
include ActiveSupport::TaggedLogging::Formatter
|
7
|
+
|
4
8
|
def call(severity, time, progname, msg)
|
5
9
|
message = msg.delete(:message)
|
6
|
-
metadata = msg.map {|k,v| "#{k}=#{v}" }
|
10
|
+
metadata = msg.map {|k,v| "#{k}=#{v}" }
|
11
|
+
|
12
|
+
message.prepend "#{tags_text}" unless current_tags.empty?
|
13
|
+
message << " #{metadata.join(' ')}" unless metadata.empty?
|
7
14
|
|
8
|
-
"#{message}
|
15
|
+
"#{message}\n"
|
9
16
|
end
|
10
17
|
end
|
11
18
|
end
|
@@ -2,7 +2,7 @@ module Hickory
|
|
2
2
|
module LogSubscribers
|
3
3
|
class ActionController < ActiveSupport::LogSubscriber
|
4
4
|
def process_action(event)
|
5
|
-
return if Hickory.ignore_if.present? && Hickory.ignore_if.call(event)
|
5
|
+
return if Hickory::Rails.ignore_if.present? && Hickory::Rails.ignore_if.call(event)
|
6
6
|
|
7
7
|
payload = event.payload
|
8
8
|
default_keys = %i[method format controller action user_id request_id]
|
data/lib/hickory/logger.rb
CHANGED
@@ -34,7 +34,16 @@ module Hickory
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
|
-
end
|
38
|
-
end
|
39
37
|
|
40
|
-
|
38
|
+
delegate :push_tags, :pop_tags, :clear_tags!, to: :formatter
|
39
|
+
|
40
|
+
def tagged(*tags)
|
41
|
+
formatter.tagged(*tags) { yield self }
|
42
|
+
end
|
43
|
+
|
44
|
+
def flush
|
45
|
+
clear_tags!
|
46
|
+
super if defined?(super)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'active_support/log_subscriber'
|
2
|
+
require 'active_support/core_ext/module/attribute_accessors'
|
3
|
+
|
4
|
+
require 'hickory/rails/railtie'
|
5
|
+
require 'hickory/log_subscribers/action_controller'
|
6
|
+
require 'hickory/log_subscribers/action_mailer'
|
7
|
+
require 'hickory/log_subscribers/active_job'
|
8
|
+
|
9
|
+
module Hickory
|
10
|
+
module Rails
|
11
|
+
module_function
|
12
|
+
|
13
|
+
mattr_accessor :application, :ignore_if
|
14
|
+
|
15
|
+
def setup(app)
|
16
|
+
self.application = app
|
17
|
+
self.ignore_if = config.ignore_if
|
18
|
+
|
19
|
+
remove_existing_log_subscriptions
|
20
|
+
Hickory::LogSubscribers::ActionController.attach_to :action_controller
|
21
|
+
Hickory::LogSubscribers::ActionMailer.attach_to :action_mailer
|
22
|
+
Hickory::LogSubscribers::ActiveJob.attach_to :active_job
|
23
|
+
end
|
24
|
+
|
25
|
+
def config
|
26
|
+
application.config.hickory
|
27
|
+
end
|
28
|
+
|
29
|
+
def remove_existing_log_subscriptions
|
30
|
+
ActiveSupport::LogSubscriber.log_subscribers.each do |subscriber|
|
31
|
+
case subscriber
|
32
|
+
when ActionView::LogSubscriber
|
33
|
+
unsubscribe(:action_view, subscriber)
|
34
|
+
when ActionController::LogSubscriber
|
35
|
+
unsubscribe(:action_controller, subscriber)
|
36
|
+
when ActionMailer::LogSubscriber
|
37
|
+
unsubscribe(:action_mailer, subscriber)
|
38
|
+
when ActiveJob::Logging::LogSubscriber
|
39
|
+
unsubscribe(:active_job, subscriber)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def unsubscribe(component, subscriber)
|
45
|
+
events = subscriber.public_methods(false).reject { |method| method.to_s == 'call' }
|
46
|
+
events.each do |event|
|
47
|
+
ActiveSupport::Notifications.notifier.listeners_for("#{event}.#{component}").each do |listener|
|
48
|
+
if listener.instance_variable_get('@delegate') == subscriber
|
49
|
+
ActiveSupport::Notifications.unsubscribe listener
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails/railtie'
|
2
|
+
require 'active_support/ordered_options'
|
3
|
+
|
4
|
+
module Hickory
|
5
|
+
module Rails
|
6
|
+
class Railtie < ::Rails::Railtie
|
7
|
+
config.hickory = ActiveSupport::OrderedOptions.new
|
8
|
+
config.hickory.enabled = false
|
9
|
+
|
10
|
+
config.after_initialize do |app|
|
11
|
+
Hickory::Rails.setup(app) if app.config.hickory.enabled
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/hickory/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hickory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- blahed
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: railties
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.1'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: bundler
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +80,20 @@ dependencies:
|
|
52
80
|
- - "~>"
|
53
81
|
- !ruby/object:Gem::Version
|
54
82
|
version: '5.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: mocha
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.9.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.9.0
|
55
97
|
description:
|
56
98
|
email:
|
57
99
|
- trvsdnn@gmail.com
|
@@ -70,15 +112,14 @@ files:
|
|
70
112
|
- bin/setup
|
71
113
|
- hickory.gemspec
|
72
114
|
- lib/hickory.rb
|
73
|
-
- lib/hickory/ext/rails/rack/logger.rb
|
74
115
|
- lib/hickory/formatters/json.rb
|
75
116
|
- lib/hickory/formatters/simple.rb
|
76
117
|
- lib/hickory/log_subscribers/action_controller.rb
|
77
118
|
- lib/hickory/log_subscribers/action_mailer.rb
|
78
119
|
- lib/hickory/log_subscribers/active_job.rb
|
79
|
-
- lib/hickory/log_subscribers/base.rb
|
80
120
|
- lib/hickory/logger.rb
|
81
|
-
- lib/hickory/
|
121
|
+
- lib/hickory/rails.rb
|
122
|
+
- lib/hickory/rails/railtie.rb
|
82
123
|
- lib/hickory/version.rb
|
83
124
|
homepage:
|
84
125
|
licenses:
|
@@ -99,8 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
140
|
- !ruby/object:Gem::Version
|
100
141
|
version: '0'
|
101
142
|
requirements: []
|
102
|
-
|
103
|
-
rubygems_version: 2.5.2
|
143
|
+
rubygems_version: 3.0.3
|
104
144
|
signing_key:
|
105
145
|
specification_version: 4
|
106
146
|
summary: An opinionated logger for rails and ruby.
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'active_support/concern'
|
2
|
-
require 'rails/rack/logger'
|
3
|
-
|
4
|
-
module Rails
|
5
|
-
module Rack
|
6
|
-
# Overwrites defaults of Rails::Rack::Logger that cause
|
7
|
-
# unnecessary logging.
|
8
|
-
# This effectively removes the log lines from the log
|
9
|
-
# that say:
|
10
|
-
# Started GET / for 192.168.2.1...
|
11
|
-
class Logger
|
12
|
-
# Overwrites Rails 3.2 code that logs new requests
|
13
|
-
def call_app(*args)
|
14
|
-
env = args.last
|
15
|
-
@app.call(env)
|
16
|
-
ensure
|
17
|
-
ActiveSupport::LogSubscriber.flush_all!
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'action_pack'
|
3
|
-
require 'active_support/core_ext/class/attribute'
|
4
|
-
require 'active_support/log_subscriber'
|
5
|
-
# require 'action_view/log_subscriber'
|
6
|
-
# require 'action_controller/log_subscriber'
|
7
|
-
# require 'request_store'
|
8
|
-
|
9
|
-
module Hickory
|
10
|
-
module LogSubscribers
|
11
|
-
class Base < ActiveSupport::LogSubscriber
|
12
|
-
# def logger
|
13
|
-
# Lograge.logger.presence || super
|
14
|
-
# end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
# def process_main_event(event)
|
19
|
-
# # return if Lograge.ignore?(event)
|
20
|
-
#
|
21
|
-
# payload = event.payload
|
22
|
-
# data = extract_request(event, payload)
|
23
|
-
# data = before_format(data, payload)
|
24
|
-
# formatted_message = Lograge.formatter.call(data)
|
25
|
-
# logger.send(Lograge.log_level, formatted_message)
|
26
|
-
# end
|
27
|
-
#
|
28
|
-
# def extract_request(event, payload)
|
29
|
-
# data = initial_data(payload)
|
30
|
-
# data.merge!(extract_status(payload))
|
31
|
-
# data.merge!(extract_runtimes(event, payload))
|
32
|
-
# data.merge!(extract_location)
|
33
|
-
# data.merge!(extract_unpermitted_params)
|
34
|
-
# data.merge!(custom_options(event))
|
35
|
-
# end
|
36
|
-
#
|
37
|
-
# %i(initial_data extract_status extract_runtimes
|
38
|
-
# extract_location extract_unpermitted_params).each do |method_name|
|
39
|
-
# define_method(method_name) { |*_arg| {} }
|
40
|
-
# end
|
41
|
-
#
|
42
|
-
# def extract_status(payload)
|
43
|
-
# if (status = payload[:status])
|
44
|
-
# { status: status.to_i }
|
45
|
-
# elsif (error = payload[:exception])
|
46
|
-
# exception, message = error
|
47
|
-
# { status: get_error_status_code(exception), error: "#{exception}: #{message}" }
|
48
|
-
# else
|
49
|
-
# { status: 0 }
|
50
|
-
# end
|
51
|
-
# end
|
52
|
-
#
|
53
|
-
# def get_error_status_code(exception)
|
54
|
-
# status = ActionDispatch::ExceptionWrapper.rescue_responses[exception]
|
55
|
-
# Rack::Utils.status_code(status)
|
56
|
-
# end
|
57
|
-
#
|
58
|
-
# def custom_options(event)
|
59
|
-
# options = Lograge.custom_options(event) || {}
|
60
|
-
# options.merge event.payload[:custom_payload] || {}
|
61
|
-
# end
|
62
|
-
#
|
63
|
-
# def before_format(data, payload)
|
64
|
-
# Lograge.before_format(data, payload)
|
65
|
-
# end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
data/lib/hickory/railtie.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rails/railtie'
|
2
|
-
require 'active_support/ordered_options'
|
3
|
-
|
4
|
-
# require 'hickory/log_subscribers/base'
|
5
|
-
require 'hickory/log_subscribers/action_controller'
|
6
|
-
require 'hickory/log_subscribers/action_mailer'
|
7
|
-
require 'hickory/log_subscribers/active_job'
|
8
|
-
|
9
|
-
module Hickory
|
10
|
-
class Railtie < Rails::Railtie
|
11
|
-
config.hickory = ActiveSupport::OrderedOptions.new
|
12
|
-
config.hickory.canonical_request_lines = false
|
13
|
-
|
14
|
-
config.after_initialize do |app|
|
15
|
-
Hickory.initialize_canonical_logs(app) if app.config.hickory.canonical_request_lines
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|