editmode 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/editmode.rb +23 -2
- data/lib/editmode/logger.rb +28 -0
- data/lib/editmode/monkey_patches.rb +17 -0
- data/lib/editmode/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c2cf39ab030f4bc6d04678170c164d950a4bf947659906c6da343537f447bd4
|
4
|
+
data.tar.gz: 89a6a0f4a16d51541404f1f1c0fd8ab90e0ad799b6bc176c28c48e8f653c0064
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3815cd743139b4fd6a354c072d9bd2c8d010c8fa4aa2a6a6e04165f363430a5689d91a1228e5e3789b8d53a9f0434c4175a525bb3d7f85c4105bcecf81d1e96
|
7
|
+
data.tar.gz: fcb8a9260a0cd706ad049c2f2dfd9406c3c3bc2ac8addcb6fa74f662709d483a00e338613136959762c5f317798cde9ad9f8d48ce0077fe63cdac323ccd063d4
|
data/lib/editmode.rb
CHANGED
@@ -6,7 +6,8 @@ require 'editmode/auto_include_filter'
|
|
6
6
|
require 'editmode/chunk_value'
|
7
7
|
require 'editmode/railtie' if defined? Rails
|
8
8
|
require 'editmode/engine' if defined?(Rails)
|
9
|
-
|
9
|
+
require 'editmode/monkey_patches'
|
10
|
+
require 'editmode/logger'
|
10
11
|
module Editmode
|
11
12
|
class << self
|
12
13
|
include Editmode::ActionViewExtensions::EditmodeHelper
|
@@ -20,6 +21,18 @@ module Editmode
|
|
20
21
|
config.project_id
|
21
22
|
end
|
22
23
|
|
24
|
+
def logger
|
25
|
+
config.logger
|
26
|
+
end
|
27
|
+
|
28
|
+
def log_level
|
29
|
+
config.log_level
|
30
|
+
end
|
31
|
+
|
32
|
+
def log_level=(level)
|
33
|
+
config.log_level = level
|
34
|
+
end
|
35
|
+
|
23
36
|
def access_token
|
24
37
|
config.access_token
|
25
38
|
end
|
@@ -43,11 +56,19 @@ module Editmode
|
|
43
56
|
|
44
57
|
class Configuration
|
45
58
|
attr_accessor :access_token, :variable
|
46
|
-
attr_reader :project_id
|
59
|
+
attr_reader :project_id, :log_level
|
60
|
+
|
61
|
+
def logger
|
62
|
+
@logger ||= Editmode::Logger.new
|
63
|
+
end
|
47
64
|
|
48
65
|
def project_id=(id)
|
49
66
|
@project_id = id
|
67
|
+
end
|
50
68
|
|
69
|
+
def log_level=(level)
|
70
|
+
@log_level = level
|
71
|
+
logger.log_level = level
|
51
72
|
end
|
52
73
|
end
|
53
74
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
|
3
|
+
module Editmode
|
4
|
+
class Logger
|
5
|
+
attr_accessor :httparty_subscription
|
6
|
+
|
7
|
+
def log_level=(level)
|
8
|
+
if level == :normal
|
9
|
+
# Add more subscription here
|
10
|
+
enable_httparty!
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def enable_httparty!
|
15
|
+
@httparty_subscription = ActiveSupport::Notifications.subscribe('request.httparty') do |name, start, ending, transaction_id, payload|
|
16
|
+
event = ActiveSupport::Notifications::Event.new(name, start, ending, transaction_id, payload)
|
17
|
+
Rails.logger.info " HTTParty -- " + "#{event.payload[:method]} #{event.payload[:url]} (Duration: #{event.duration}ms)"
|
18
|
+
Thread.current[:http_runtime] ||= 0
|
19
|
+
Thread.current[:http_runtime] += event.duration
|
20
|
+
payload[:http_runtime] = event.duration
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def unsubscribe(subscriber)
|
25
|
+
ActiveSupport::Notifications.unsubscribe(subscriber) if subscriber.present?
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
# Support logging on httparty requests
|
4
|
+
module HTTParty
|
5
|
+
class Request
|
6
|
+
alias_method :_original_perform, :perform
|
7
|
+
def perform(&block)
|
8
|
+
payload = {
|
9
|
+
method: http_method.const_get(:METHOD),
|
10
|
+
url: uri
|
11
|
+
}
|
12
|
+
ActiveSupport::Notifications.instrument 'request.httparty', payload do
|
13
|
+
_original_perform(&block)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/editmode/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: editmode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Ennis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -85,6 +85,8 @@ files:
|
|
85
85
|
- lib/editmode/chunk_value.rb
|
86
86
|
- lib/editmode/engine.rb
|
87
87
|
- lib/editmode/helper.rb
|
88
|
+
- lib/editmode/logger.rb
|
89
|
+
- lib/editmode/monkey_patches.rb
|
88
90
|
- lib/editmode/railtie.rb
|
89
91
|
- lib/editmode/script_tag.rb
|
90
92
|
- lib/editmode/version.rb
|