debug_logging 3.1.9 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +174 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/LICENSE.txt +1 -1
- data/README.md +89 -47
- data/SECURITY.md +2 -2
- data/lib/debug_logging/active_support_notifications.rb +0 -2
- data/lib/debug_logging/argument_printer.rb +25 -19
- data/lib/debug_logging/class_logger.rb +1 -3
- data/lib/debug_logging/class_notifier.rb +11 -15
- data/lib/debug_logging/configuration.rb +27 -20
- data/lib/debug_logging/constants.rb +11 -9
- data/lib/debug_logging/finalize.rb +0 -2
- data/lib/debug_logging/hooks.rb +12 -16
- data/lib/debug_logging/instance_logger.rb +45 -19
- data/lib/debug_logging/instance_logger_modulizer.rb +55 -51
- data/lib/debug_logging/instance_notifier.rb +18 -18
- data/lib/debug_logging/instance_notifier_modulizer.rb +35 -41
- data/lib/debug_logging/log_subscriber.rb +2 -4
- data/lib/debug_logging/util.rb +17 -0
- data/lib/debug_logging/version.rb +1 -3
- data/lib/debug_logging.rb +45 -22
- data/lib/simple_debug_logging.rb +2 -4
- data.tar.gz.sig +0 -0
- metadata +14 -29
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca22c0dbc789a56d7f02d3ef685d92fb0423592bde3fccaa733afcd577c88a78
|
4
|
+
data.tar.gz: 279bdd5ecde603ff0be14ec128bea893a05a53d0d4c0f42fbdb6663964fff178
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 352720fb350ee3c404f64b631c6f27f178ca8bb07b66e779cb26a66077708df9e716f7b0ef49e80035f44a45bc8081e436f420a14ac07f17d44a6b7e67ba46d1
|
7
|
+
data.tar.gz: 5effc5e2ef194e6e90c9c57f3378523a6fda0d5ab2b4d5fd7c4161bc542385b9796cfef56f015a756a75ead1969bb83f94c81d3dc4ba54607b7d9e2adab4c46f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
### Added
|
10
|
+
### Changed
|
11
|
+
### Fixed
|
12
|
+
### Removed
|
13
|
+
|
14
|
+
## [4.0.1] ([tag][4.0.1t]) - 2024-03-01
|
15
|
+
### Added
|
16
|
+
- Support for all Numeric types to be used as monotonic timestamps for ActiveSupport::Notifications
|
17
|
+
- `time_formatter_proc` - used to format timestamp added to beginning of log lines
|
18
|
+
- `add_timestamp` - Add timestamp to front of each log line
|
19
|
+
### Changed
|
20
|
+
- `DebugLogging::ArgumentPrinter.debug_time_to_s` => `DebugLogging::ArgumentPrinter.debug_event_time_to_s`
|
21
|
+
### Fixed
|
22
|
+
### Removed
|
23
|
+
|
24
|
+
## [4.0.0] ([tag][4.0.0t]) - 2024-02-28
|
25
|
+
### Added
|
26
|
+
- Class method DSL:
|
27
|
+
- `logged`
|
28
|
+
- Instance method DSL:
|
29
|
+
- `i_logged`
|
30
|
+
### Changed
|
31
|
+
- Class method DSL renamed:
|
32
|
+
- `notifies` => `notified`
|
33
|
+
- Instance method DSL renamed:
|
34
|
+
- `i_notifies` => `i_notified`
|
35
|
+
- Disambiguated class method log output send message separator:
|
36
|
+
- `.` => `::`, because `.` is ambiguous; same call syntax used for instance method calls
|
37
|
+
### Fixed
|
38
|
+
- Per method config for every decorated method
|
39
|
+
### Removed
|
40
|
+
- Support for `include DebugLogging::InstanceLogger.new(...)`
|
41
|
+
- Support for `include DebugLogging::InstanceNotifier.new(...)`
|
42
|
+
|
43
|
+
## [3.1.9] ([tag][3.1.9t]) - 2023-10-31
|
44
|
+
### Fixed
|
45
|
+
- Maximum Ruby version is 2.7. Versions 3.x are not compatible with Ruby >= 3
|
46
|
+
|
47
|
+
## [3.1.8] ([tag][3.1.8t]) - 2020-12-19
|
48
|
+
|
49
|
+
## [3.1.7] ([tag][3.1.7t]) - 2020-12-19
|
50
|
+
|
51
|
+
## [3.1.6] ([tag][3.1.6t]) - tagged, but unreleased
|
52
|
+
|
53
|
+
## [3.1.5] ([tag][3.1.5t]) - 2020-12-18
|
54
|
+
|
55
|
+
## [3.1.4] ([tag][3.1.4t]) - 2020-12-18
|
56
|
+
|
57
|
+
## [3.1.3] ([tag][3.1.3t]) - 2020-12-18
|
58
|
+
|
59
|
+
## [3.1.2] ([tag][3.1.2t]) - 2020-12-10
|
60
|
+
|
61
|
+
## [3.1.1] ([tag][3.1.1t]) - 2020-12-09
|
62
|
+
|
63
|
+
## [3.1.0] ([tag][3.1.0t]) - 2020-10-24
|
64
|
+
|
65
|
+
## [3.0.0] ([tag][3.0.0t]) - 2020-10-07
|
66
|
+
|
67
|
+
## [2.0.0] ([tag][2.0.0t]) - 2020-10-06
|
68
|
+
|
69
|
+
## [1.0.17] ([tag][1.0.17t]) - 2018-09-10
|
70
|
+
|
71
|
+
## [1.0.16] ([tag][1.0.16t]) - 2018-01-16
|
72
|
+
|
73
|
+
## [1.0.15] ([tag][1.0.15t]) - 2017-10-17
|
74
|
+
|
75
|
+
## [1.0.14] ([tag][1.0.14t]) - 2017-10-09
|
76
|
+
|
77
|
+
## [1.0.13] ([tag][1.0.13t]) - 2017-10-08
|
78
|
+
|
79
|
+
## [1.0.12] ([tag][1.0.12t]) - 2017-10-08
|
80
|
+
|
81
|
+
## [1.0.11] ([tag][1.0.11t]) - 2017-10-06
|
82
|
+
|
83
|
+
## [1.0.10] ([tag][1.0.10t]) - 2017-09-26
|
84
|
+
|
85
|
+
## [1.0.9] ([tag][1.0.9t]) - 2017-09-06
|
86
|
+
|
87
|
+
## [1.0.8] ([tag][1.0.8t]) - 2017-09-06
|
88
|
+
|
89
|
+
## [1.0.7] ([tag][1.0.7t]) - 2017-09-06
|
90
|
+
|
91
|
+
## [1.0.6] ([tag][1.0.6t]) - 2017-09-05
|
92
|
+
|
93
|
+
## [1.0.5] ([tag][1.0.5t]) - 2017-03-31
|
94
|
+
|
95
|
+
## [1.0.4] ([tag][1.0.4t]) - 2017-03-31
|
96
|
+
|
97
|
+
## [1.0.3] ([tag][1.0.3t]) - 2017-03-31
|
98
|
+
|
99
|
+
## [1.0.2] ([tag][1.0.2t]) - 2017-03-30
|
100
|
+
|
101
|
+
## [1.0.1] ([tag][1.0.1t]) - 2017-03-29
|
102
|
+
|
103
|
+
## [1.0.0] ([tag][1.0.0t]) - 2017-03-26
|
104
|
+
|
105
|
+
## [0.1.0] ([tag][0.1.0t]) - 2017-03-25
|
106
|
+
- Initial release
|
107
|
+
|
108
|
+
[Unreleased]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v4.0.1...HEAD
|
109
|
+
[4.0.1t]: https://gitlab.com/pboling/debug_logging/-/tags/v4.0.1
|
110
|
+
[4.0.1]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v4.0.0...v4.0.1
|
111
|
+
[4.0.0t]: https://gitlab.com/pboling/debug_logging/-/tags/v4.0.0
|
112
|
+
[4.0.0]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.9...v4.0.0
|
113
|
+
[3.1.9t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.9
|
114
|
+
[3.1.9]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.8...v3.1.9
|
115
|
+
[3.1.8t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.8
|
116
|
+
[3.1.8]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.7...v3.1.8
|
117
|
+
[3.1.7t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.7
|
118
|
+
[3.1.7]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.6...v3.1.7
|
119
|
+
[3.1.6t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.6
|
120
|
+
[3.1.6]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.5...v3.1.6
|
121
|
+
[3.1.5t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.5
|
122
|
+
[3.1.5]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.4...v3.1.5
|
123
|
+
[3.1.4t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.4
|
124
|
+
[3.1.4]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.3...v3.1.4
|
125
|
+
[3.1.3t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.3
|
126
|
+
[3.1.3]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.2...v3.1.3
|
127
|
+
[3.1.2t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.2
|
128
|
+
[3.1.2]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.1...v3.1.2
|
129
|
+
[3.1.1t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.1
|
130
|
+
[3.1.1]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.0...v3.1.1
|
131
|
+
[3.1.0t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.0
|
132
|
+
[3.1.0]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.0.0...v3.1.0
|
133
|
+
[3.0.0t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.0.0
|
134
|
+
[3.0.0]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v2.0.0...v3.0.0
|
135
|
+
[2.0.0t]: https://gitlab.com/pboling/debug_logging/-/tags/v2.0.0
|
136
|
+
[2.0.0]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.17...v2.0.0
|
137
|
+
[1.0.17t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.17
|
138
|
+
[1.0.17]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.16...v1.0.17
|
139
|
+
[1.0.16t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.16
|
140
|
+
[1.0.16]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.15...v1.0.16
|
141
|
+
[1.0.15t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.15
|
142
|
+
[1.0.15]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.14...v1.0.15
|
143
|
+
[1.0.14t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.14
|
144
|
+
[1.0.14]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.13...v1.0.14
|
145
|
+
[1.0.13t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.13
|
146
|
+
[1.0.13]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.12...v1.0.13
|
147
|
+
[1.0.12t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.12
|
148
|
+
[1.0.12]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.11...v1.0.12
|
149
|
+
[1.0.11t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.11
|
150
|
+
[1.0.11]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.10...v1.0.11
|
151
|
+
[1.0.10t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.10
|
152
|
+
[1.0.10]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.9...v1.0.10
|
153
|
+
[1.0.9t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.9
|
154
|
+
[1.0.9]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.8...v1.0.9
|
155
|
+
[1.0.8t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.8
|
156
|
+
[1.0.8]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.7...v1.0.8
|
157
|
+
[1.0.7t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.7
|
158
|
+
[1.0.7]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.6...v1.0.7
|
159
|
+
[1.0.6t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.6
|
160
|
+
[1.0.6]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.5...v1.0.6
|
161
|
+
[1.0.5t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.5
|
162
|
+
[1.0.5]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.4...v1.0.5
|
163
|
+
[1.0.4t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.4
|
164
|
+
[1.0.4]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.3...v1.0.4
|
165
|
+
[1.0.3t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.3
|
166
|
+
[1.0.3]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.2...v1.0.3
|
167
|
+
[1.0.2t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.2
|
168
|
+
[1.0.2]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.1...v1.0.2
|
169
|
+
[1.0.1t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.1
|
170
|
+
[1.0.1]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.0...v1.0.1
|
171
|
+
[1.0.0t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.0
|
172
|
+
[1.0.0]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v0.1.0...v1.0.0
|
173
|
+
[0.1.0t]: https://gitlab.com/pboling/debug_logging/-/tags/v0.1.0
|
174
|
+
[0.1.0]: https://gitlab.com/pboling/debug_logging/-/compare/f648ea6832aa85232d320b4c4acc4a84e44a83d3...v0.1.0
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at peter.boling@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2017-
|
3
|
+
Copyright (c) 2017-2024 Peter Boling (railsbling.com)
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -26,8 +26,9 @@
|
|
26
26
|
[🖇sponsor]: https://github.com/sponsors/pboling
|
27
27
|
|
28
28
|
|
29
|
-
Unobtrusive, inheritable-overridable-configurable, drop-in debug logging,
|
30
|
-
|
29
|
+
Unobtrusive, inheritable-overridable-configurable, drop-in debug logging, instrumented via method decorators.
|
30
|
+
Don't leave a mess behind when it is time to remove logging!
|
31
|
+
Supports `ActiveSupport::Notifications` (thanks [@jgillson](https://github.com/jgillson)). Optional ActiveRecord callback-style hooks that you can decorate your methods with. Hooks logic was taken from the [`slippy_method_hooks` gem](https://github.com/guckin/slippy_method_hooks), (thanks [@guckin](https://github.com/guckin)), and prefaced with `debug_` for this implementation. `DebugLogging::Finalize` is lightly modified from [this stackoverflow answer](https://stackoverflow.com/a/34559282).
|
31
32
|
|
32
33
|
## What do I mean by "unobtrusive"?
|
33
34
|
|
@@ -35,17 +36,17 @@ Supports ActiveSupport::Notifications (thanks [@jgillson](https://github.com/jgi
|
|
35
36
|
|
36
37
|
**Unobtrusive** debug logging stays out of the method, changes no logic, can't break your code, and yet it still runs when your method is called, and tells you everything you wanted to know. It doesn't mess with the git history of the method at all!
|
37
38
|
|
38
|
-
| Project | DebugLogging
|
39
|
-
|
40
|
-
| install | `bundle add debug_logging`
|
41
|
-
| compatibility | Ruby >= 2.4
|
42
|
-
| license | [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
|
43
|
-
| download rank | [![Downloads Today](https://img.shields.io/gem/rd/debug_logging.svg)](https://github.com/pboling/debug_logging)
|
44
|
-
| version | [![Version](https://img.shields.io/gem/v/debug_logging.svg)](https://rubygems.org/gems/debug_logging)
|
45
|
-
| code triage | [![Open Source Helpers](https://www.codetriage.com/pboling/debug_logging/badges/users.svg)](https://www.codetriage.com/pboling/debug_logging)
|
46
|
-
| documentation | [on RDoc.info][documentation]
|
47
|
-
| live chat | [![Join the chat at https://gitter.im/pboling/debug_logging](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/pboling/debug_logging?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
48
|
-
| expert support | [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github)
|
39
|
+
| Project | DebugLogging |
|
40
|
+
|------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
41
|
+
| install | `bundle add debug_logging` |
|
42
|
+
| compatibility | Ruby >= 3.1 (use version 3.x for Ruby 2.4 - 2.7 compatibility) |
|
43
|
+
| license | [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) |
|
44
|
+
| download rank | [![Downloads Today](https://img.shields.io/gem/rd/debug_logging.svg)](https://github.com/pboling/debug_logging) |
|
45
|
+
| version | [![Version](https://img.shields.io/gem/v/debug_logging.svg)](https://rubygems.org/gems/debug_logging) |
|
46
|
+
| code triage | [![Open Source Helpers](https://www.codetriage.com/pboling/debug_logging/badges/users.svg)](https://www.codetriage.com/pboling/debug_logging) |
|
47
|
+
| documentation | [on RDoc.info][documentation] |
|
48
|
+
| live chat | [![Join the chat at https://gitter.im/pboling/debug_logging](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/pboling/debug_logging?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) |
|
49
|
+
| expert support | [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github) |
|
49
50
|
| Spread ~♡ⓛⓞⓥⓔ♡~ | [🌏](https://about.me/peter.boling), [👼](https://angel.co/peter-boling), [![Liberapay Patrons][⛳liberapay-img]][⛳liberapay] [![Follow Me on LinkedIn][🖇linkedin-img]][🖇linkedin] [![Find Me on WellFound:][✌️wellfound-img]][✌️wellfound] [![My Blog][🚎blog-img]][🚎blog] [![Follow Me on Twitter][🐦twitter-img]][🐦twitter] |
|
50
51
|
|
51
52
|
[🚎dl-cwf]: https://github.com/pboling/debug_logging/actions/workflows/current.yml
|
@@ -87,26 +88,25 @@ Supports ActiveSupport::Notifications (thanks [@jgillson](https://github.com/jgi
|
|
87
88
|
|
88
89
|
Herein you will find:
|
89
90
|
|
90
|
-
* Classes inheriting from Module
|
91
|
+
* ~~Classes inheriting from Module~~ Refactored to use standard Modules and `prepend`!
|
91
92
|
* Zero tolerance policy on monkey patching
|
92
93
|
* When the gem is loaded there are no monkey patches.
|
93
94
|
* Rather, your own classes/methods get "patched" and "hooked" as you configure them.
|
94
95
|
* 100% clean, 0% obtrusive
|
95
|
-
* Greater than
|
96
|
+
* Greater than 94% test coverage & 82% branch coverage
|
96
97
|
* 100% Ruby 2.1+ compatible
|
97
98
|
- use version `gem "debug_logging", "~> 1.0"` for Ruby < 2.3
|
98
99
|
- use version `gem "debug_logging", "~> 2.0"` for Ruby 2.3
|
99
100
|
- use version `gem "debug_logging", "~> 3.1"` for Ruby >= 2.4, < 3
|
100
|
-
-
|
101
|
-
|
102
|
-
NOTE: The manner this is made to work for class methods is totally different than the way this is made to work for instance methods.
|
101
|
+
- apologies to Ruby 3.0, which is hiding under a blanket
|
102
|
+
- use version `gem "debug_logging", "~> 4.0"` for Ruby >= 3.1
|
103
103
|
|
104
104
|
## Installation
|
105
105
|
|
106
106
|
Add this line to your application's Gemfile:
|
107
107
|
|
108
108
|
```ruby
|
109
|
-
gem "debug_logging", "~>
|
109
|
+
gem "debug_logging", "~> 4.0"
|
110
110
|
```
|
111
111
|
|
112
112
|
And then execute:
|
@@ -148,7 +148,7 @@ Recommend creating `config/initializers/debug_logging.rb`, or adding to `config/
|
|
148
148
|
```ruby
|
149
149
|
# Showing the defaults
|
150
150
|
DebugLogging.configuration.logger = Logger.new($stdout) # you probably want to override to be the Rails.logger, and if so you can't set it in the initializer, as it needs to be set after Rails.logger is set.
|
151
|
-
DebugLogging.configuration.log_level = :debug # at what level
|
151
|
+
DebugLogging.configuration.log_level = :debug # at what level are the messages created by this gem sent at?
|
152
152
|
DebugLogging.configuration.multiple_last_hashes = false # pass every hash argument to last_hash_to_s_proc?
|
153
153
|
DebugLogging.configuration.last_hash_to_s_proc = nil # e.g. ->(hash) { "keys: #{hash.keys}" }
|
154
154
|
DebugLogging.configuration.last_hash_max_length = 1_000
|
@@ -160,6 +160,8 @@ DebugLogging.configuration.active_support_notifications = false
|
|
160
160
|
DebugLogging.configuration.colorized_chain_for_method = false # e.g. ->(colorized_string) { colorized_string.red.on_blue.underline }
|
161
161
|
DebugLogging.configuration.colorized_chain_for_class = false # e.g. ->(colorized_string) { colorized_string.colorize(:light_blue ).colorize( :background => :red) }
|
162
162
|
DebugLogging.configuration.add_invocation_id = true # identify a method call uniquely in a log, pass a proc for colorization, e.g. ->(colorized_string) { colorized_string.light_black }
|
163
|
+
DebugLogging.configuration.time_formatter_proc = DebugLogging::Constants::DEFAULT_TIME_FORMATTER
|
164
|
+
DebugLogging.configuration.add_timestamp = false
|
163
165
|
DebugLogging.configuration.ellipsis = " ✂️ …".freeze
|
164
166
|
DebugLogging.configuration.mark_scope_exit = true # Only has an effect if benchmarking is off, since benchmarking always marks the scope exit
|
165
167
|
DebugLogging.configuration.add_payload = false # or a proc which will be called to print the payload
|
@@ -183,6 +185,8 @@ DebugLogging.configure do |config|
|
|
183
185
|
config.active_support_notifications = false
|
184
186
|
config.colorized_chain_for_method = false # e.g. ->(colorized_string) { colorized_string.red.on_blue.underline }
|
185
187
|
config.colorized_chain_for_class = false # e.g. ->(colorized_string) { colorized_string.colorize(:light_blue ).colorize( :background => :red) }
|
188
|
+
config.time_formatter_proc = DebugLogging::Constants::DEFAULT_TIME_FORMATTER
|
189
|
+
config.add_timestamp = false
|
186
190
|
config.add_invocation_id = true # identify a method call uniquely in a log, pass a proc for colorization, e.g. ->(colorized_string) { colorized_string.light_black }
|
187
191
|
config.ellipsis = " ✂️ …".freeze
|
188
192
|
config.mark_scope_exit = true # Only has an effect if benchmarking is off, since benchmarking always marks the scope exit
|
@@ -199,9 +203,16 @@ Just prepend `debug_` to any config value you want to override in a class.
|
|
199
203
|
Just prepend `debug_` to any config value you want to override on an instance of a class.
|
200
204
|
|
201
205
|
**All** of the above **config** is **inheritable** and **configurable** at the **per-method** level as well!
|
202
|
-
Just send along a hash of the config options
|
206
|
+
Just send along a hash of the config options, similar to the following:
|
207
|
+
|
208
|
+
- `logged :drive, { ellipsis: " ✂️ it out" }`
|
209
|
+
- `i_logged [:drive, :stop], { ellipsis: " ✂️ 2 much" }`
|
210
|
+
- `notified :drive, { ellipsis: " ✂️ it out" }`
|
211
|
+
- `i_notified [:drive, :stop], { ellipsis: " ✂️ 2 much" }`
|
212
|
+
|
213
|
+
See the example class below, and the specs.
|
203
214
|
|
204
|
-
**NOTE ON** `Rails.logger` - It will probably be nil in your initializer, so setting the `config.logger` to `Rails.logger` there will result in setting it to `nil`, which means the default will end up being used: `Logger.new(
|
215
|
+
**NOTE ON** `Rails.logger` - It will probably be nil in your initializer, so setting the `config.logger` to `Rails.logger` there will result in setting it to `nil`, which means the default will end up being used: `Logger.new($stdout)`. Instead just config the logger in your application.rb, or anytime later, but *before your classes get loaded* and start inheriting the config:
|
205
216
|
|
206
217
|
```ruby
|
207
218
|
DebugLogging.configuration.logger = Rails.logger
|
@@ -222,9 +233,10 @@ class Car
|
|
222
233
|
|
223
234
|
# For class methods
|
224
235
|
# Provides the versatile `logged` method decorator / macro
|
236
|
+
extend DebugLogging::ClassLogger
|
225
237
|
# For instance methods
|
226
238
|
# Provides the versatile `i_logged` method decorator / macro
|
227
|
-
extend DebugLogging::
|
239
|
+
extend DebugLogging::InstanceLogger
|
228
240
|
|
229
241
|
# == BEGIN CLASS METHODS ==
|
230
242
|
# For class methods:
|
@@ -260,8 +272,12 @@ class Car
|
|
260
272
|
|
261
273
|
# == BEGIN INSTANCE METHODS ==
|
262
274
|
# For instance methods:
|
263
|
-
# Option 1: specify the exact method(s) to add logging to
|
264
|
-
|
275
|
+
# Option 1: specify the exact method(s) to add logging to, and optionally customize
|
276
|
+
i_notified [
|
277
|
+
:drive,
|
278
|
+
:stop,
|
279
|
+
[:turn, {instance_variables: %i[direction angle]}],
|
280
|
+
]
|
265
281
|
|
266
282
|
def drive(speed)
|
267
283
|
speed
|
@@ -273,16 +289,42 @@ class Car
|
|
273
289
|
|
274
290
|
# For instance methods:
|
275
291
|
# Option 2: add logging to all instance methods defined above (but *not* defined below)
|
276
|
-
|
292
|
+
i_logged instance_methods(false)
|
277
293
|
|
278
294
|
def faster(**_opts)
|
279
|
-
|
295
|
+
5
|
280
296
|
end
|
281
297
|
|
282
298
|
# Override configuration options for any instance method(s), by passing a hash as the last argument
|
283
299
|
# In the last hash any non-Configuration keys will be data that gets logged,
|
284
300
|
# and also made available to last_hash_to_s_proc
|
285
|
-
|
301
|
+
# Here's an example that sets every possible option, while also showing what the default values are!
|
302
|
+
i_logged [:faster], {
|
303
|
+
logger: Logger.new($stdout), # probably want to override to be the Rails.logger
|
304
|
+
log_level: :debug, # at what level do the messages created by this gem sent at?
|
305
|
+
multiple_last_hashes: false,
|
306
|
+
last_hash_to_s_proc: nil, # e.g. ->(hash) { "keys: #{hash.keys}" }
|
307
|
+
last_hash_max_length: 1_000,
|
308
|
+
args_to_s_proc: nil, # e.g. ->(*record) { "record id: #{record.first.id}" }
|
309
|
+
args_max_length: 1_000,
|
310
|
+
colorized_chain_for_method: false, # e.g. ->(colorized_string) { colorized_string.red.on_blue.underline }
|
311
|
+
colorized_chain_for_class: false, # e.g. ->(colorized_string) { colorized_string.colorize(:light_blue ).colorize( :background => :red) }
|
312
|
+
add_invocation_id: true, # allows unique identification of method call; association of entry and exit log lines
|
313
|
+
ellipsis: " ✂️ …".freeze,
|
314
|
+
mark_scope_exit: false,
|
315
|
+
add_payload: true, # Can also be a proc returning a string, which will be called when printing the payload
|
316
|
+
payload_max_length: 1_000,
|
317
|
+
error_handler_proc: nil,
|
318
|
+
time_formatter_proc: DebugLogging::Constants::DEFAULT_TIME_FORMATTER,
|
319
|
+
add_timestamp: false,
|
320
|
+
instance_benchmarks: false,
|
321
|
+
class_benchmarks: false,
|
322
|
+
}
|
323
|
+
|
324
|
+
# You can also use `i_logged` as a true method decorator:
|
325
|
+
i_logged def slower
|
326
|
+
2
|
327
|
+
end
|
286
328
|
|
287
329
|
def will_not_be_logged
|
288
330
|
false
|
@@ -313,28 +355,28 @@ Every time a method is called, class and instance method events are instrumented
|
|
313
355
|
class Car
|
314
356
|
# Adds the helper methods to the class.
|
315
357
|
# All helpers prefixed with debug_*,
|
316
|
-
# except for the *
|
358
|
+
# except for the *notified* decorator, which comes from extending DebugLogging::ClassNotifier
|
317
359
|
extend DebugLogging
|
360
|
+
# For instance methods
|
361
|
+
# Provides the versatile `i_notified` method decorator / macro
|
362
|
+
extend DebugLogging::InstanceNotifier
|
363
|
+
# For class methods
|
364
|
+
# Provides the versatile `notified` method decorator / macro
|
365
|
+
extend DebugLogging::ClassNotifier
|
318
366
|
|
319
367
|
# For instance methods:
|
320
368
|
# Option 1: specify the exact method(s) to add instrumentation to
|
321
369
|
# NOTE: You can capture instance variable values as part of the event payload
|
322
|
-
|
370
|
+
i_notified [
|
323
371
|
:drive,
|
324
372
|
:stop,
|
325
373
|
[:turn, {instance_variables: %i[direction angle]}],
|
326
|
-
]
|
327
|
-
|
328
|
-
# For class methods
|
329
|
-
# Provides the versatile `notifies` method decorator / macro
|
330
|
-
# For instance methods
|
331
|
-
# Provides the versatile `i_notifies` method decorator / macro
|
332
|
-
extend DebugLogging::ClassNotifier
|
374
|
+
]
|
333
375
|
|
334
376
|
# == BEGIN CLASS METHODS ==
|
335
377
|
# For class methods:
|
336
|
-
# Option 1: Use *
|
337
|
-
|
378
|
+
# Option 1: Use *notified* as a method decorator
|
379
|
+
notified def self.make
|
338
380
|
new
|
339
381
|
end
|
340
382
|
def self.design(*_args)
|
@@ -350,13 +392,13 @@ class Car
|
|
350
392
|
end
|
351
393
|
|
352
394
|
# Option 2: Use *logged* as a macro
|
353
|
-
|
395
|
+
notified :design, :safety
|
354
396
|
# Override configuration options for any class method(s), by passing a hash as the last argument
|
355
397
|
# In the last hash any non-Configuration keys will be data that gets added to the event payload,
|
356
398
|
# and also made available to last_hash_to_s_proc
|
357
|
-
|
358
|
-
something: "here", #
|
359
|
-
add_invocation_id: false, #
|
399
|
+
notified :dealer_options, {
|
400
|
+
something: "here", # <== will be added to the event payload, and be available to last_hash_to_s_proc
|
401
|
+
add_invocation_id: false, # <== Overrides config
|
360
402
|
}
|
361
403
|
def self.will_not_be_notified
|
362
404
|
false
|
@@ -373,8 +415,8 @@ class Car
|
|
373
415
|
end
|
374
416
|
|
375
417
|
# For instance methods:
|
376
|
-
# Option 2: add instrumentation to all instance methods defined above (but *not* defined below)
|
377
|
-
|
418
|
+
# Option 2: add notification instrumentation to all instance methods defined above (but *not* defined below)
|
419
|
+
i_notified instance_methods(false)
|
378
420
|
|
379
421
|
def faster(**_opts)
|
380
422
|
0
|
@@ -383,7 +425,7 @@ class Car
|
|
383
425
|
# Override options for any instance method(s), by passing a hash as the last argument
|
384
426
|
# In the last hash any non-Configuration keys will be data that gets added to the event payload,
|
385
427
|
# and also made available to last_hash_to_s_proc
|
386
|
-
|
428
|
+
i_notified [:faster], {add_invocation_id: false}
|
387
429
|
|
388
430
|
def will_not_be_notified
|
389
431
|
false
|
@@ -433,7 +475,7 @@ the [Pessimistic Version Constraint][📌pvc] with two digits of precision.
|
|
433
475
|
For example:
|
434
476
|
|
435
477
|
```ruby
|
436
|
-
spec.add_dependency("debug_logging", "~>
|
478
|
+
spec.add_dependency("debug_logging", "~> 4.0")
|
437
479
|
```
|
438
480
|
|
439
481
|
[comment]: <> ( VERSIONING LINKS )
|
data/SECURITY.md
CHANGED