technologic 0.23.4 → 0.24.0
Sign up to get free protection for your applications and to get access to all the features.
- 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: 52a6e844d98ed256add1a8c2c5d11945dd5597c0e644d091131fa915660c4372
|
4
|
+
data.tar.gz: 1940dae0ce9b81276619169b839177318006401e1b06e3ba9f5abb97f2cb97a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0a2810468d56201704d74aa896291dfa83a94c4e2d4d991e7dcf54d8f20b3fdc681d770a4c729c0d49fc6a3295813086b3a93e032803acac3a8ade07ad9b29d
|
7
|
+
data.tar.gz: 624da89c51c1598b9ebd657398fb3d8a29c4df474f40f5198193c5d807c4a7f96d25b43af16f7bf7e01d447c9ad5979b47dffcf3c8a913a42055981a90081080
|
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.24.0
|
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-07-28 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.24.0
|
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.24.0
|
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.24.0
|
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
|