technologic 0.23.7 → 0.25.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 +4 -4
- data/README.md +34 -0
- data/lib/technologic/config_options.rb +19 -0
- data/lib/technologic/event.rb +5 -1
- data/lib/technologic/setup.rb +7 -0
- data/lib/technologic/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 963a8a4e9bd65397546fdf836975388005ae17bb07aa1d2debf6931f5d5fb70e
|
4
|
+
data.tar.gz: 4a2beee34bcffd776b5c8e243853d7b3ddb343be9a61616183614b5ef3ce061a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 393b0f65f6db28ce7ba2df74d44ef0295b2f294e55aab62657e72796bca62a1b2b4667aa69ae9b74e0c17117fd6eff020b42c49b88c9a5bc90b50460cb7ae39e
|
7
|
+
data.tar.gz: a47641269f0fbb1a7e791f0018ef81a4f0a36a58bda5b04c4c93fa4ebd991934ac04bb220f9d66790372accb79747c8c1f590ce135cd16c542c17f32d3052404
|
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
|
data/lib/technologic/event.rb
CHANGED
@@ -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
|
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
|
data/lib/technologic/setup.rb
CHANGED
@@ -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
|
data/lib/technologic/version.rb
CHANGED
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.
|
4
|
+
version: 0.25.2
|
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-
|
11
|
+
date: 2020-10-16 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.
|
33
|
+
version: 0.25.2
|
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.
|
40
|
+
version: 0.25.2
|
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.
|
90
|
+
documentation_uri: https://www.rubydoc.info/gems/technologic/0.25.2
|
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.
|
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
|