Created
March 5, 2026 04:16
-
-
Save bettse/0a456b7a0d791fcde49afd436694d7e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Logger < ::ActiveSupport::Logger | |
| def with_field(key, value) | |
| Thread.current['lograge.data'] ||= {} | |
| Thread.current['lograge.data'][key] = value | |
| return self | |
| end | |
| def with_fields(hash) | |
| if hash.is_a?(Hash) | |
| Thread.current['lograge.data'] ||= {} | |
| Thread.current['lograge.data'].merge!(hash) | |
| end | |
| return self | |
| end | |
| def with_local_fields(hash) | |
| if hash.is_a?(Hash) | |
| Thread.current[LOCAL_LOG_FIELDS] ||= {} | |
| Thread.current[LOCAL_LOG_FIELDS].merge!(hash) | |
| end | |
| yield(self) if block_given? | |
| return self | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment