technologic 0.23.8 → 0.25.3

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: 27e46a1e94a51aaabbbd362368d96d3682bdca681e255a26b4978a0c66b4ad67
4
- data.tar.gz: 95d009c3dfdeecf5eaf5d818663643b40b94f805db9363fad8eff9693b897f63
3
+ metadata.gz: 2fac527e781d749fb20e815bfc288adc1e22a40297e80a75805e1632442886c0
4
+ data.tar.gz: 9a4244bdafac62e23eb0019e1d85b1d892641191faf80c780cf70610b2a88790
5
5
  SHA512:
6
- metadata.gz: 3780668c0537e015849f5e0d57d66da3873dc647973994f7e1a5d9697136cbcd6dcc5f6a9f9f1c015a9498d8d4e4796b315ea9928f406167970301721ab06ac4
7
- data.tar.gz: b456592170d1411b1739ffd5ad186634d82596e4716caa7388a13f54d681ae264d1fd6c4e7bb3c22d5641b1a478c248bf9e979fa5f20accd0d6e7cbe902f44e4
6
+ metadata.gz: 16d11b6464725b8a451c7633853c2c7e3d74e51ddf4b10504fc9071567101737e0b77d0441378be164a6ed297b055dbcdddda3757ceb899eda3a0dba74060dd8
7
+ data.tar.gz: a958d41ac5d074e01560decd34c1f3f66fb4ededba5baa4c9b60ffec516e6ad3e63ffe066bdd02248cbd13dac07e2a1097c7ec28bbb931fa7655bf256829565d
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.8"
5
+ VERSION = "0.25.3"
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.8
4
+ version: 0.25.3
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-06-09 00:00:00.000000000 Z
11
+ date: 2020-12-23 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.8
33
+ version: 0.25.3
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.8
40
+ version: 0.25.3
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.8
90
+ documentation_uri: https://www.rubydoc.info/gems/technologic/0.25.3
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.1.2
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