technologic 0.23.6 → 0.25.1

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
2
  SHA256:
3
- metadata.gz: 9e2555a534bf3ddf34969d3481a984b2f1edb65290afeaa7320cc468bd414ae1
4
- data.tar.gz: 2077f2bf684c77db114a4170478d0e133b0c9b56a6884f67d5f727a464160661
3
+ metadata.gz: 235ef4113251dd4e7af4aa97d8048ffe017e27b70e6a0052bf9f9371bfd99a0a
4
+ data.tar.gz: 39c501d0a9ddbc770958c5dc3ea1caeaad60e70bf85a5c9f92c3f9da070a5978
5
5
  SHA512:
6
- metadata.gz: 678a0a08cff447e4162d98c4e89e14467f5a2c246939ef413005ae89132af4d9518a8504f286f0f8c59191f743e248138b8d61e7ada26ed4439a97ccd015a87a
7
- data.tar.gz: 8c1a7053c7bc916cd55f422ffad965a25fec8b5dff67233a1e360b885deb729c9c323eb2c90a9d9b3c5070c3ba2965ac169a58bdfd14fd36c6524542e3d8acdf
6
+ metadata.gz: 4d41e9dddbf5c37c730ec4e4ff3120e7bc78e25524ab6f89f92402a4d168ff932eaf5b7b421d8e67cd1348febb03da9ec8c4e5b7946077f3e01ab37567be443d
7
+ data.tar.gz: 773014349cfbfc35fd0cc00823584956aefae5c1597f58f36fb1c2065ea354b612fdd2b889277f14c0b342d50c81ffe5847983ec3d5ebc8034733b21788db9cf
data/README.md CHANGED
@@ -53,6 +53,40 @@ error :email_for_user_does_not_exist, user_id: @user.email
53
53
  fatal :it_is_going_to_be_a_long_day, need_to_know: info_dump
54
54
  ```
55
55
 
56
+ If given a block, these methods will include the runtime duration of the given block after the code is evaluated:
57
+ ```ruby
58
+ info :something_happening_in_here, extra_data: "I really need this data" do
59
+ sleep 0.5
60
+ puts "Important things happening here!"
61
+ end
62
+
63
+ # Results in:
64
+
65
+ Important things happening here!
66
+ {"extra_data":"I really need this data","event":"something_happening_in_here.Object","duration":503.745,"@timestamp":"2020-07-27T20:05:06.355-04:00","@version":"1","severity":"INFO","host":"localhost"}
67
+ ```
68
+
69
+ ### Configuration
70
+
71
+ _TODO: Improve me_
72
+
73
+ * `log_duration_in_ms` - Boolean; default: false
74
+
75
+ By default, Technologic will log duration as a float in seconds. To log duration as milliseconds instead, set it in your application config:
76
+
77
+ ```ruby
78
+ # Rails app - in application.rb
79
+ Rails.application.configure do |config|
80
+ ...
81
+ technologic.log_duration_in_ms = true
82
+ end
83
+
84
+ # For a plain ol' Ruby app with no Railties:
85
+ Technologic::ConfigOptions.log_duration_in_ms = true
86
+ ```
87
+
88
+ **NOTE:** In a future version of Technologic, the default will change from `false` to `true`
89
+
56
90
  ## Development
57
91
 
58
92
  Consult Spicerack's [development instructions](../README.md#development) for more info.
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Technologic
4
4
  class ConfigOptions
5
+ include AroundTheWorld
6
+
5
7
  class_attribute :enabled, default: true
6
8
 
7
9
  class_attribute :subscribe_to_fatal, default: true
@@ -15,5 +17,22 @@ module Technologic
15
17
  class_attribute :log_warn_events, default: true
16
18
  class_attribute :log_info_events, default: true
17
19
  class_attribute :log_debug_events, default: true
20
+
21
+ class_attribute :log_duration_in_ms, default: false
22
+
23
+ # TODO: Remove with duration-as-seconds deprecation
24
+ class << self
25
+ around_method :log_duration_in_ms= do |*args|
26
+ super(*args).tap do
27
+ @_log_duration_in_ms_set_explicitly = true
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def log_duration_in_ms_set_explicitly?
34
+ !!@_log_duration_in_ms_set_explicitly
35
+ end
36
+ end
18
37
  end
19
38
  end
@@ -4,6 +4,8 @@ module Technologic
4
4
  class Event
5
5
  include ShortCircuIt
6
6
 
7
+ LOGGABLE_DURATION_THRESHOLD_MS = 0.04
8
+
7
9
  attr_reader :name, :duration
8
10
 
9
11
  def initialize(name, started, finished, payload)
@@ -13,10 +15,12 @@ module Technologic
13
15
  end
14
16
 
15
17
  def data
18
+ duration_in_ms = duration * 1000
19
+
16
20
  {}.tap do |hash|
17
21
  hash.merge!(@payload)
18
22
  hash[:event] = name
19
- hash[:duration] = duration if duration.round > 0
23
+ hash[:duration] = ConfigOptions.log_duration_in_ms ? duration_in_ms : duration if duration_in_ms > LOGGABLE_DURATION_THRESHOLD_MS
20
24
  end
21
25
  end
22
26
  memoize :data
@@ -8,6 +8,7 @@ module Technologic
8
8
 
9
9
  setup_subscribers(technologic_config)
10
10
  setup_loggers(technologic_config)
11
+ warn_duration_unit_not_set(technologic_config)
11
12
  end
12
13
 
13
14
  private
@@ -27,6 +28,12 @@ module Technologic
27
28
  Technologic::InfoSubscriber.on_event { |e| Technologic::Logger.log(:info, e) } if config.log_info_events
28
29
  Technologic::DebugSubscriber.on_event { |e| Technologic::Logger.log(:debug, e) } if config.log_debug_events
29
30
  end
31
+
32
+ def warn_duration_unit_not_set(config)
33
+ return if config.__send__(:log_duration_in_ms_set_explicitly?)
34
+
35
+ warn "WARNING: Technologic.log_duration_in_ms is not set. In a future version of Technologic, the default value will change from false to true. To maintain existing behavior, set `application.config.technologic.log_duration_in_ms = false` explicitly."
36
+ end
30
37
  end
31
38
  end
32
39
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Technologic
4
4
  # This constant is managed by spicerack
5
- VERSION = "0.23.6"
5
+ VERSION = "0.25.1"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: technologic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.6
4
+ version: 0.25.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Garside
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-14 00:00:00.000000000 Z
11
+ date: 2020-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.23.6
33
+ version: 0.25.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.23.6
40
+ version: 0.25.1
41
41
  description: A clean and terse way to produce standardized, highly actionable, and
42
42
  data-rich logs
43
43
  email:
@@ -87,7 +87,7 @@ metadata:
87
87
  homepage_uri: https://github.com/Freshly/spicerack/tree/master/technologic
88
88
  source_code_uri: https://github.com/Freshly/spicerack/tree/master/technologic
89
89
  changelog_uri: https://github.com/Freshly/spicerack/blob/master/technologic/CHANGELOG.md
90
- documentation_uri: https://www.rubydoc.info/gems/technologic/0.23.6
90
+ documentation_uri: https://www.rubydoc.info/gems/technologic/0.25.1
91
91
  post_install_message:
92
92
  rdoc_options: []
93
93
  require_paths:
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []
106
- rubygems_version: 3.0.3
106
+ rubygems_version: 3.1.4
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: Logging system built on an extensible event triggering system requiring minimal