Skip to content

Instantly share code, notes, and snippets.

@gshutler
Created January 10, 2013 21:27
Show Gist options
  • Save gshutler/4505944 to your computer and use it in GitHub Desktop.
Save gshutler/4505944 to your computer and use it in GitHub Desktop.
Example of nested diagnostic contexts with Hatchet
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