Created
January 10, 2013 21:27
-
-
Save gshutler/4505944 to your computer and use it in GitHub Desktop.
Example of nested diagnostic contexts with Hatchet
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 Example | |
include Hatchet | |
def run | |
log.info { "Hello" } | |
# => "Example - Hello" | |
log.ndc.scope(:nest) do | |
log.info { "Hi" } | |
# => "Example nest - Hi" | |
end | |
log.info { "Back out" } | |
# => "Example - Back out" | |
add_context | |
log.info { "Maintained for thread" } | |
# => "Example more_context - Maintained for thread" | |
log.ndc.pop | |
log.info { "Removed" } | |
# => "Example - Removed" | |
end | |
def add_context | |
log.ndc.push(:more_context) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment