rack-action_logger 0.1.9 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22b077d4a3c2233f2cc7ad125f6327a38097439c
4
- data.tar.gz: 7afbcbfe31b62c9062529e271038d432527c271e
3
+ metadata.gz: decd5af4f47d90252f92d6442c7642b486681d47
4
+ data.tar.gz: 55096e953ae0a64a26c3e364d64a6579f3c33084
5
5
  SHA512:
6
- metadata.gz: 294f9871ddd3695e7b1f3bfff2583029172a3e9ac45384901b3120ebb38881be1a97a07ecbf91a2d46f5c10150ac610cbc4784050af5ac2cdb6b930380c9ad59
7
- data.tar.gz: 2e90f1d3f4abdb0024203c4fc4041c8c8b629f61f4930d4beb51948fb593a3a01766bdff2a970ea6e09ff44e217c6f693edd93852d40e4c3a3750d2c347b049c
6
+ metadata.gz: 2e8fff404973516a228d9df8fa9f8b649bde879a200f12d71a6d43249fd77958165167038d87deca3d38c828db353dcf7b8e41f67675eb2fa8862b8e4c1a7509
7
+ data.tar.gz: cdfcdf11d86bf527f3b66f8e4df80f1b1d6966581e6d599729c7674bcc4dc81b9af29bdefe69051a4a208bd1fbdcd8fe857eebd279f3977c7ae27e1016a9d4f6
data/.simplecov ADDED
@@ -0,0 +1,3 @@
1
+ SimpleCov.start do
2
+ add_group 'lib', 'lib'
3
+ end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack-action_logger (0.1.9)
4
+ rack-action_logger (0.2.0)
5
5
  activesupport
6
6
  fluent-logger (~> 0.5)
7
7
  woothee (~> 1.4)
@@ -16,9 +16,11 @@ GEM
16
16
  tzinfo (~> 1.1)
17
17
  concurrent-ruby (1.0.2)
18
18
  diff-lcs (1.2.5)
19
+ docile (1.1.5)
19
20
  fluent-logger (0.6.1)
20
21
  msgpack (>= 0.5.6, < 2)
21
22
  i18n (0.7.0)
23
+ json (2.0.2)
22
24
  minitest (5.9.1)
23
25
  msgpack (1.0.2)
24
26
  rack (2.0.1)
@@ -38,6 +40,11 @@ GEM
38
40
  diff-lcs (>= 1.2.0, < 2.0)
39
41
  rspec-support (~> 3.5.0)
40
42
  rspec-support (3.5.0)
43
+ simplecov (0.12.0)
44
+ docile (~> 1.1.0)
45
+ json (>= 1.8, < 3)
46
+ simplecov-html (~> 0.10.0)
47
+ simplecov-html (0.10.0)
41
48
  thread_safe (0.3.5)
42
49
  tzinfo (1.2.2)
43
50
  thread_safe (~> 0.1)
@@ -52,6 +59,7 @@ DEPENDENCIES
52
59
  rack-test (~> 0.6.3)
53
60
  rake (~> 10.0)
54
61
  rspec (~> 3.0)
62
+ simplecov
55
63
 
56
64
  BUNDLED WITH
57
65
  1.13.6
data/README.md CHANGED
@@ -144,7 +144,7 @@ Request can be customized by creating new class for rack_metrics configuration.
144
144
  Add the following code to any code on any times.
145
145
 
146
146
  ```ruby
147
- Rack::ActionLogger::Container.set_append_log({ value: 'ok' }, 'activities')
147
+ Rack::ActionLogger::Container.add_append_log({ value: 'ok' }, 'activities')
148
148
  ```
149
149
 
150
150
  ### Add Model Logger
@@ -189,7 +189,7 @@ class TestWorker < ApplicationController
189
189
 
190
190
  def perform(title, context)
191
191
  Rack::ActionLogger::Emitter.new.emit(context) do
192
- Rack::ActionLogger::Container.set_append_log({ title: title }, 'worker')
192
+ Rack::ActionLogger::Container.add_append_log({ title: title }, 'worker')
193
193
  p 'work: title=' + title
194
194
  end
195
195
  end
@@ -17,7 +17,7 @@ module Rack::ActionLogger
17
17
  record["_#{column_name}"] = self.try(column_name)
18
18
  end
19
19
  record = Rack::ActionLogger::ParameterFiltering.apply_filter(record)
20
- Rack::ActionLogger::Container.set_append_log(record, "model_#{self.class.table_name}")
20
+ Rack::ActionLogger::Container.add_append_log(record, "model_#{self.class.table_name}")
21
21
  end
22
22
 
23
23
  def capture_action_log_update
@@ -31,7 +31,7 @@ module Rack::ActionLogger
31
31
  end
32
32
  end
33
33
  record = Rack::ActionLogger::ParameterFiltering.apply_filter(record)
34
- Rack::ActionLogger::Container.set_append_log(record, "model_#{self.class.table_name}")
34
+ Rack::ActionLogger::Container.add_append_log(record, "model_#{self.class.table_name}")
35
35
  end
36
36
 
37
37
  def capture_action_log_destroy
@@ -42,7 +42,7 @@ module Rack::ActionLogger
42
42
  end
43
43
  end
44
44
  record = Rack::ActionLogger::ParameterFiltering.apply_filter(record)
45
- Rack::ActionLogger::Container.set_append_log(record, "model_#{self.class.table_name}")
45
+ Rack::ActionLogger::Container.add_append_log(record, "model_#{self.class.table_name}")
46
46
  end
47
47
  end
48
48
  end
@@ -12,31 +12,31 @@ module Rack::ActionLogger
12
12
  Thread.current[THREAD_KEY] = nil
13
13
  end
14
14
 
15
- def set_is_emit_started
16
- store[:rack_action_logger_emit_started] = true
15
+ def is_emit_started=(value)
16
+ store[:rack_action_logger_emit_started] = value
17
17
  end
18
18
 
19
- def get_is_emit_started
19
+ def is_emit_started
20
20
  store[:rack_action_logger_emit_started] ||= false
21
21
  end
22
22
 
23
- def set_append_log(hash, tag=nil)
23
+ def add_append_log(hash, tag=nil)
24
24
  return unless is_valid_hash hash
25
25
  return unless is_valid_tag tag
26
26
  hash[:tag] = tag
27
- get_append_logs.push(hash)
27
+ append_logs.push(hash)
28
28
  end
29
29
 
30
- def get_append_logs
30
+ def append_logs
31
31
  store[:rack_action_logger_append_logs] ||= []
32
32
  end
33
33
 
34
34
  def merge_attributes(attributes)
35
35
  return unless is_valid_hash attributes
36
- get_attributes.merge! attributes
36
+ self.attributes = self.attributes.merge! attributes
37
37
  end
38
38
 
39
- def get_attributes
39
+ def attributes
40
40
  store[:rack_action_logger_attributes] ||= {}
41
41
  end
42
42
 
@@ -44,20 +44,18 @@ module Rack::ActionLogger
44
44
  return unless is_valid_hash hash
45
45
  return unless is_valid_tag tag
46
46
  hash[:tag] = tag
47
- get_request_log.merge! hash
47
+ self.request_log = hash
48
48
  end
49
49
 
50
- def get_request_log
50
+ def request_log
51
51
  store[:rack_action_logger_request_log] ||= {}
52
52
  end
53
53
 
54
54
  def export
55
- # ここenumerableで置き換える
56
- hash = {}
57
- EXPORT_KEYS.each do |key|
58
- hash[key] = store[key] if store[key]
55
+ EXPORT_KEYS.inject({}) do |result, key|
56
+ result[key] = store[key] if store[key]
57
+ result
59
58
  end
60
- hash
61
59
  end
62
60
 
63
61
  def import(hash)
@@ -90,6 +88,14 @@ module Rack::ActionLogger
90
88
  false
91
89
  end
92
90
  end
91
+
92
+ def attributes=(value)
93
+ store[:rack_action_logger_attributes] = value
94
+ end
95
+
96
+ def request_log=(value)
97
+ store[:rack_action_logger_request_log] = value
98
+ end
93
99
  end
94
100
 
95
101
  end
@@ -2,7 +2,7 @@ module Rack::ActionLogger
2
2
  class Emitter
3
3
 
4
4
  def initialize
5
- @can_emit = !Container.get_is_emit_started
5
+ @can_emit = !Container.is_emit_started
6
6
  unless @can_emit
7
7
  Rack::ActionLogger.logger.error("#{self.class} is already defined.")
8
8
  Rack::ActionLogger.logger.error("#{Thread.current.backtrace.join("\n")}")
@@ -12,7 +12,7 @@ module Rack::ActionLogger
12
12
  end
13
13
 
14
14
  def emit(context=nil)
15
- @container.set_is_emit_started
15
+ @container.is_emit_started = true
16
16
  @container.import(context) if context
17
17
  result = yield
18
18
  emit_all_logs # emit log unless exception raised
@@ -30,16 +30,16 @@ module Rack::ActionLogger
30
30
  end
31
31
 
32
32
  def emit_request_log
33
- return unless (@container.get_request_log.is_a?(Hash) && @container.get_request_log != {})
34
- hash = @container.get_request_log.merge @container.get_attributes
33
+ return unless (@container.request_log.is_a?(Hash) && @container.request_log != {})
34
+ hash = @container.request_log.merge @container.attributes
35
35
  hash = format_tag(hash)
36
36
  @emit_adapter.emit(hash)
37
37
  end
38
38
 
39
39
  def emit_append_logs
40
- @container.get_append_logs.each do |hash|
40
+ @container.append_logs.each do |hash|
41
41
  hash = format_tag(hash)
42
- @emit_adapter.emit(@container.get_attributes.merge(hash))
42
+ @emit_adapter.emit(@container.attributes.merge(hash))
43
43
  end
44
44
  end
45
45
 
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module ActionLogger
3
- VERSION = '0.1.9'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -32,4 +32,5 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency 'rake', '~> 10.0'
33
33
  spec.add_development_dependency 'rspec', '~> 3.0'
34
34
  spec.add_development_dependency 'rack-test', '~> 0.6.3'
35
+ spec.add_development_dependency 'simplecov'
35
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-action_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koichi Ishida
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-22 00:00:00.000000000 Z
11
+ date: 2016-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.6.3
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  description: Rack::ActionLogger is a tool to log user activity
112
126
  email:
113
127
  - wapa5pow@gmail.com
@@ -117,6 +131,7 @@ extra_rdoc_files: []
117
131
  files:
118
132
  - ".gitignore"
119
133
  - ".rspec"
134
+ - ".simplecov"
120
135
  - ".travis.yml"
121
136
  - CODE_OF_CONDUCT.md
122
137
  - Gemfile