debug_logging 3.1.9 ā 4.0.0
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 +160 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/LICENSE.txt +1 -1
- data/README.md +62 -45
- data/lib/debug_logging/active_support_notifications.rb +0 -2
- data/lib/debug_logging/argument_printer.rb +7 -7
- data/lib/debug_logging/class_logger.rb +1 -3
- data/lib/debug_logging/class_notifier.rb +11 -15
- data/lib/debug_logging/configuration.rb +18 -20
- data/lib/debug_logging/constants.rb +0 -2
- data/lib/debug_logging/finalize.rb +0 -2
- data/lib/debug_logging/hooks.rb +12 -16
- data/lib/debug_logging/instance_logger.rb +23 -19
- data/lib/debug_logging/instance_logger_modulizer.rb +51 -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 +0 -2
- data/lib/debug_logging/util.rb +1 -0
- data/lib/debug_logging/version.rb +1 -3
- data/lib/debug_logging.rb +29 -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: 80eec636fd64a69b41aaf67704b79c784bc5ffa989e181c51106bc908bc645c8
|
4
|
+
data.tar.gz: 8feca3ec5aadd298bc0da9f75631834f4a16bd73aa9d39572c8caf72ec2834b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd13ad1dca5706140626730a48dc4e9133efc5e3db3d55f64b4c79f3a0bb21765d82a237c2a021d93ec2b4d0632d4a0a4bc5a3c28ef2bad088de9de37d6fdc3e
|
7
|
+
data.tar.gz: 9be10f369557ed872853e387870528c0a64df4981c854b3df6b27d22f0d24eac741d51e69beec9c6e6cfd2398748838d47ac5955df951d906d77378f60d4331a
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,160 @@
|
|
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.0] - unreleased
|
15
|
+
### Added
|
16
|
+
- Class method DSL:
|
17
|
+
- `logged`
|
18
|
+
- Instance method DSL:
|
19
|
+
- `i_logged`
|
20
|
+
### Changed
|
21
|
+
- Class method DSL renamed:
|
22
|
+
- `notifies` => `notified`
|
23
|
+
- Instance method DSL renamed:
|
24
|
+
- `i_notifies` => `i_notified`
|
25
|
+
- Disambiguated class method log output send message separator:
|
26
|
+
- `.` => `::`, because `.` is ambiguous; same call syntax used for instance method calls
|
27
|
+
### Fixed
|
28
|
+
- Per method config for every decorated method
|
29
|
+
### Removed
|
30
|
+
- Support for `include DebugLogging::InstanceLogger.new(...)`
|
31
|
+
- Support for `include DebugLogging::InstanceNotifier.new(...)`
|
32
|
+
|
33
|
+
## [3.1.9] - 2023-10-31
|
34
|
+
### Fixed
|
35
|
+
- Maximum Ruby version is 2.7. Versions 3.x are not compatible with Ruby >= 3
|
36
|
+
|
37
|
+
## [3.1.8] - 2020-12-19
|
38
|
+
|
39
|
+
## [3.1.7] - 2020-12-19
|
40
|
+
|
41
|
+
## [3.1.6] - tagged, but unreleased
|
42
|
+
|
43
|
+
## [3.1.5] - 2020-12-18
|
44
|
+
|
45
|
+
## [3.1.4] - 2020-12-18
|
46
|
+
|
47
|
+
## [3.1.3] - 2020-12-18
|
48
|
+
|
49
|
+
## [3.1.2] - 2020-12-10
|
50
|
+
|
51
|
+
## [3.1.1] - 2020-12-09
|
52
|
+
|
53
|
+
## [3.1.0] - 2020-10-24
|
54
|
+
|
55
|
+
## [3.0.0] - 2020-10-07
|
56
|
+
|
57
|
+
## [2.0.0] - 2020-10-06
|
58
|
+
|
59
|
+
## [1.0.17] - 2018-09-10
|
60
|
+
|
61
|
+
## [1.0.16] - 2018-01-16
|
62
|
+
|
63
|
+
## [1.0.15] - 2017-10-17
|
64
|
+
|
65
|
+
## [1.0.14] - 2017-10-09
|
66
|
+
|
67
|
+
## [1.0.13] - 2017-10-08
|
68
|
+
|
69
|
+
## [1.0.12] - 2017-10-08
|
70
|
+
|
71
|
+
## [1.0.11] - 2017-10-06
|
72
|
+
|
73
|
+
## [1.0.10] - 2017-09-26
|
74
|
+
|
75
|
+
## [1.0.9] - 2017-09-06
|
76
|
+
|
77
|
+
## [1.0.8] - 2017-09-06
|
78
|
+
|
79
|
+
## [1.0.7] - 2017-09-06
|
80
|
+
|
81
|
+
## [1.0.6] - 2017-09-05
|
82
|
+
|
83
|
+
## [1.0.5] ([tag][1.0.1t]) - 2017-03-31
|
84
|
+
|
85
|
+
## [1.0.4] ([tag][1.0.4t]) - 2017-03-31
|
86
|
+
|
87
|
+
## [1.0.3] ([tag][1.0.3t]) - 2017-03-31
|
88
|
+
|
89
|
+
## [1.0.2] ([tag][1.0.2t]) - 2017-03-30
|
90
|
+
|
91
|
+
## [1.0.1] ([tag][1.0.1t]) - 2017-03-29
|
92
|
+
|
93
|
+
## [1.0.0] ([tag][1.0.0t]) - 2017-03-26
|
94
|
+
|
95
|
+
## [0.1.0] ([tag][0.1.0t]) - 2017-03-25
|
96
|
+
- Initial release
|
97
|
+
|
98
|
+
[Unreleased]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.9...HEAD
|
99
|
+
[3.1.9t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.9
|
100
|
+
[3.1.9]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.8...v3.1.9
|
101
|
+
[3.1.8t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.8
|
102
|
+
[3.1.8]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.7...v3.1.8
|
103
|
+
[3.1.7t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.7
|
104
|
+
[3.1.7]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.6...v3.1.7
|
105
|
+
[3.1.6t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.6
|
106
|
+
[3.1.6]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.5...v3.1.6
|
107
|
+
[3.1.5t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.5
|
108
|
+
[3.1.5]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.4...v3.1.5
|
109
|
+
[3.1.4t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.4
|
110
|
+
[3.1.4]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.3...v3.1.4
|
111
|
+
[3.1.3t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.3
|
112
|
+
[3.1.3]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.2...v3.1.3
|
113
|
+
[3.1.2t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.2
|
114
|
+
[3.1.2]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.1...v3.1.2
|
115
|
+
[3.1.1t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.1
|
116
|
+
[3.1.1]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.1.0...v3.1.1
|
117
|
+
[3.1.0t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.1.0
|
118
|
+
[3.1.0]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v3.0.0...v3.1.0
|
119
|
+
[3.0.0t]: https://gitlab.com/pboling/debug_logging/-/tags/v3.0.0
|
120
|
+
[3.0.0]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v2.0.0...v3.0.0
|
121
|
+
[2.0.0t]: https://gitlab.com/pboling/debug_logging/-/tags/v2.0.0
|
122
|
+
[2.0.0]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.17...v2.0.0
|
123
|
+
[1.0.17t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.17
|
124
|
+
[1.0.17]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.16...v1.0.17
|
125
|
+
[1.0.16t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.16
|
126
|
+
[1.0.16]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.15...v1.0.16
|
127
|
+
[1.0.15t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.15
|
128
|
+
[1.0.15]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.14...v1.0.15
|
129
|
+
[1.0.14t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.14
|
130
|
+
[1.0.14]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.13...v1.0.14
|
131
|
+
[1.0.13t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.13
|
132
|
+
[1.0.13]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.12...v1.0.13
|
133
|
+
[1.0.12t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.12
|
134
|
+
[1.0.12]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.11...v1.0.12
|
135
|
+
[1.0.11t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.11
|
136
|
+
[1.0.11]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.10...v1.0.11
|
137
|
+
[1.0.10t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.10
|
138
|
+
[1.0.10]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.9...v1.0.10
|
139
|
+
[1.0.9t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.9
|
140
|
+
[1.0.9]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.8...v1.0.9
|
141
|
+
[1.0.8t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.8
|
142
|
+
[1.0.8]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.7...v1.0.8
|
143
|
+
[1.0.7t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.7
|
144
|
+
[1.0.7]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.6...v1.0.7
|
145
|
+
[1.0.6t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.6
|
146
|
+
[1.0.6]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.5...v1.0.6
|
147
|
+
[1.0.5t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.5
|
148
|
+
[1.0.5]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.4...v1.0.5
|
149
|
+
[1.0.4t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.4
|
150
|
+
[1.0.4]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.3...v1.0.4
|
151
|
+
[1.0.3t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.3
|
152
|
+
[1.0.3]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.2...v1.0.3
|
153
|
+
[1.0.2t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.2
|
154
|
+
[1.0.2]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.1...v1.0.2
|
155
|
+
[1.0.1t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.1
|
156
|
+
[1.0.1]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v1.0.0...v1.0.1
|
157
|
+
[1.0.0t]: https://gitlab.com/pboling/debug_logging/-/tags/v1.0.0
|
158
|
+
[1.0.0]: https://gitlab.com/kettle-rb/kettle-soup-cover/-/compare/v0.1.0...v1.0.0
|
159
|
+
[0.1.0t]: https://gitlab.com/pboling/debug_logging/-/tags/v0.1.0
|
160
|
+
[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:
|
@@ -199,7 +199,14 @@ Just prepend `debug_` to any config value you want to override in a class.
|
|
199
199
|
Just prepend `debug_` to any config value you want to override on an instance of a class.
|
200
200
|
|
201
201
|
**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
|
202
|
+
Just send along a hash of the config options, similar to the following:
|
203
|
+
|
204
|
+
- `logged :drive, { ellipsis: " āļø it out" }`
|
205
|
+
- `i_logged [:drive, :stop], { ellipsis: " āļø 2 much" }`
|
206
|
+
- `notified :drive, { ellipsis: " āļø it out" }`
|
207
|
+
- `i_notified [:drive, :stop], { ellipsis: " āļø 2 much" }`
|
208
|
+
|
209
|
+
See the example class below, and the specs.
|
203
210
|
|
204
211
|
**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
212
|
|
@@ -222,9 +229,10 @@ class Car
|
|
222
229
|
|
223
230
|
# For class methods
|
224
231
|
# Provides the versatile `logged` method decorator / macro
|
232
|
+
extend DebugLogging::ClassLogger
|
225
233
|
# For instance methods
|
226
234
|
# Provides the versatile `i_logged` method decorator / macro
|
227
|
-
extend DebugLogging::
|
235
|
+
extend DebugLogging::InstanceLogger
|
228
236
|
|
229
237
|
# == BEGIN CLASS METHODS ==
|
230
238
|
# For class methods:
|
@@ -260,8 +268,12 @@ class Car
|
|
260
268
|
|
261
269
|
# == BEGIN INSTANCE METHODS ==
|
262
270
|
# For instance methods:
|
263
|
-
# Option 1: specify the exact method(s) to add logging to
|
264
|
-
|
271
|
+
# Option 1: specify the exact method(s) to add logging to, and optionally customize
|
272
|
+
i_notified [
|
273
|
+
:drive,
|
274
|
+
:stop,
|
275
|
+
[:turn, {instance_variables: %i[direction angle]}],
|
276
|
+
]
|
265
277
|
|
266
278
|
def drive(speed)
|
267
279
|
speed
|
@@ -273,16 +285,21 @@ class Car
|
|
273
285
|
|
274
286
|
# For instance methods:
|
275
287
|
# Option 2: add logging to all instance methods defined above (but *not* defined below)
|
276
|
-
|
288
|
+
i_logged instance_methods(false)
|
277
289
|
|
278
290
|
def faster(**_opts)
|
279
|
-
|
291
|
+
5
|
280
292
|
end
|
281
293
|
|
282
294
|
# Override configuration options for any instance method(s), by passing a hash as the last argument
|
283
295
|
# In the last hash any non-Configuration keys will be data that gets logged,
|
284
296
|
# and also made available to last_hash_to_s_proc
|
285
|
-
|
297
|
+
i_logged [:faster], {add_invocation_id: false}
|
298
|
+
|
299
|
+
# You can also use `i_logged` as a true method decorator:
|
300
|
+
i_logged def slower
|
301
|
+
2
|
302
|
+
end
|
286
303
|
|
287
304
|
def will_not_be_logged
|
288
305
|
false
|
@@ -313,28 +330,28 @@ Every time a method is called, class and instance method events are instrumented
|
|
313
330
|
class Car
|
314
331
|
# Adds the helper methods to the class.
|
315
332
|
# All helpers prefixed with debug_*,
|
316
|
-
# except for the *
|
333
|
+
# except for the *notified* decorator, which comes from extending DebugLogging::ClassNotifier
|
317
334
|
extend DebugLogging
|
335
|
+
# For instance methods
|
336
|
+
# Provides the versatile `i_notified` method decorator / macro
|
337
|
+
extend DebugLogging::InstanceNotifier
|
338
|
+
# For class methods
|
339
|
+
# Provides the versatile `notified` method decorator / macro
|
340
|
+
extend DebugLogging::ClassNotifier
|
318
341
|
|
319
342
|
# For instance methods:
|
320
343
|
# Option 1: specify the exact method(s) to add instrumentation to
|
321
344
|
# NOTE: You can capture instance variable values as part of the event payload
|
322
|
-
|
345
|
+
i_notified [
|
323
346
|
:drive,
|
324
347
|
:stop,
|
325
348
|
[: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
|
349
|
+
]
|
333
350
|
|
334
351
|
# == BEGIN CLASS METHODS ==
|
335
352
|
# For class methods:
|
336
|
-
# Option 1: Use *
|
337
|
-
|
353
|
+
# Option 1: Use *notified* as a method decorator
|
354
|
+
notified def self.make
|
338
355
|
new
|
339
356
|
end
|
340
357
|
def self.design(*_args)
|
@@ -350,13 +367,13 @@ class Car
|
|
350
367
|
end
|
351
368
|
|
352
369
|
# Option 2: Use *logged* as a macro
|
353
|
-
|
370
|
+
notified :design, :safety
|
354
371
|
# Override configuration options for any class method(s), by passing a hash as the last argument
|
355
372
|
# In the last hash any non-Configuration keys will be data that gets added to the event payload,
|
356
373
|
# and also made available to last_hash_to_s_proc
|
357
|
-
|
358
|
-
something: "here", #
|
359
|
-
add_invocation_id: false, #
|
374
|
+
notified :dealer_options, {
|
375
|
+
something: "here", # <== will be added to the event payload, and be available to last_hash_to_s_proc
|
376
|
+
add_invocation_id: false, # <== Overrides config
|
360
377
|
}
|
361
378
|
def self.will_not_be_notified
|
362
379
|
false
|
@@ -373,8 +390,8 @@ class Car
|
|
373
390
|
end
|
374
391
|
|
375
392
|
# For instance methods:
|
376
|
-
# Option 2: add instrumentation to all instance methods defined above (but *not* defined below)
|
377
|
-
|
393
|
+
# Option 2: add notification instrumentation to all instance methods defined above (but *not* defined below)
|
394
|
+
i_notified instance_methods(false)
|
378
395
|
|
379
396
|
def faster(**_opts)
|
380
397
|
0
|
@@ -383,7 +400,7 @@ class Car
|
|
383
400
|
# Override options for any instance method(s), by passing a hash as the last argument
|
384
401
|
# In the last hash any non-Configuration keys will be data that gets added to the event payload,
|
385
402
|
# and also made available to last_hash_to_s_proc
|
386
|
-
|
403
|
+
i_notified [:faster], {add_invocation_id: false}
|
387
404
|
|
388
405
|
def will_not_be_notified
|
389
406
|
false
|
@@ -433,7 +450,7 @@ the [Pessimistic Version Constraint][špvc] with two digits of precision.
|
|
433
450
|
For example:
|
434
451
|
|
435
452
|
```ruby
|
436
|
-
spec.add_dependency("debug_logging", "~>
|
453
|
+
spec.add_dependency("debug_logging", "~> 4.0")
|
437
454
|
```
|
438
455
|
|
439
456
|
[comment]: <> ( VERSIONING LINKS )
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require "date"
|
4
2
|
require "time"
|
5
3
|
|
@@ -9,11 +7,11 @@ module DebugLogging
|
|
9
7
|
"completed in #{format("%f", tms.real)}s (#{format("%f", tms.total)}s CPU)"
|
10
8
|
end
|
11
9
|
|
12
|
-
def debug_invocation_id_to_s(args: nil, config_proxy: nil)
|
13
|
-
return "" unless args && config_proxy
|
10
|
+
def debug_invocation_id_to_s(args: nil, kwargs: nil, config_proxy: nil)
|
11
|
+
return "" unless (args || kwargs) && config_proxy
|
14
12
|
|
15
13
|
if config_proxy.debug_add_invocation_id
|
16
|
-
invocation = " ~#{args.object_id}@#{(Time.now.to_f.to_s % "%#-21a")[4..-4]}~"
|
14
|
+
invocation = " ~#{args.object_id}|#{kwargs.object_id}@#{(Time.now.to_f.to_s % "%#-21a")[4..-4]}~"
|
17
15
|
case config_proxy.debug_add_invocation_id
|
18
16
|
when true
|
19
17
|
invocation
|
@@ -58,12 +56,14 @@ module DebugLogging
|
|
58
56
|
"#{klass_string}#{separator}#{method_string}"
|
59
57
|
end
|
60
58
|
|
61
|
-
def debug_signature_to_s(args: nil, config_proxy: nil) # rubocop:disable Metrics/CyclomaticComplexity
|
62
|
-
return "" unless args && config_proxy
|
59
|
+
def debug_signature_to_s(args: nil, kwargs: nil, config_proxy: nil) # rubocop:disable Metrics/CyclomaticComplexity
|
60
|
+
return "" unless (args || kwargs) && config_proxy
|
63
61
|
|
64
62
|
printed_args = ""
|
65
63
|
|
66
64
|
add_args_ellipsis = false
|
65
|
+
args = args.dup
|
66
|
+
args.push(kwargs) if kwargs
|
67
67
|
if config_proxy.debug_last_hash_to_s_proc && args[-1].is_a?(Hash)
|
68
68
|
add_other_args_ellipsis = false
|
69
69
|
if args.length > 1
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
module DebugLogging
|
4
2
|
module ClassLogger
|
5
3
|
def logged(*methods_to_log)
|
@@ -31,7 +29,7 @@ module DebugLogging
|
|
31
29
|
paydirt = DebugLogging::Util.payload_instance_variable_hydration(scope: self, payload: method_payload)
|
32
30
|
log_prefix = debug_invocation_to_s(
|
33
31
|
klass: to_s,
|
34
|
-
separator: "
|
32
|
+
separator: "::",
|
35
33
|
method_to_log: method_to_log,
|
36
34
|
config_proxy: config_proxy,
|
37
35
|
)
|
@@ -1,8 +1,6 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
module DebugLogging
|
4
2
|
module ClassNotifier
|
5
|
-
def
|
3
|
+
def notified(*methods_to_notify)
|
6
4
|
methods_to_notify, payload, config_opts = DebugLogging::Util.extract_payload_and_config(
|
7
5
|
method_names: methods_to_notify,
|
8
6
|
payload: nil,
|
@@ -40,18 +38,16 @@ module DebugLogging
|
|
40
38
|
**paydirt,
|
41
39
|
},
|
42
40
|
) do
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
raise e
|
54
|
-
end
|
41
|
+
if args.size == 1 && (harsh = args[0]) && harsh.is_a?(Hash)
|
42
|
+
original_method.call(**harsh, &block)
|
43
|
+
else
|
44
|
+
original_method.call(*args, &block)
|
45
|
+
end
|
46
|
+
rescue StandardError => e
|
47
|
+
if config_proxy.error_handler_proc
|
48
|
+
config_proxy.error_handler_proc.call(config_proxy, e, self, method_to_notify, args)
|
49
|
+
else
|
50
|
+
raise e
|
55
51
|
end
|
56
52
|
end
|
57
53
|
end
|