Closed asenchi closed 10 years ago
I found a bug in Scrolls, so this won't exactly work as advertised in the example code. But everything falls back to Logger, so this PR should have no effects on existing behavior.
Scrolls shipped v0.3.8 that fixes the Logger compatibility bug, so the above would output this now:
github/pygments.rb instrument-logger! : ruby ./test.rb
log_message="[2014-02-11T11:34:42-05:00] Starting pid 95864 with fd 7."
log_message='[2014-02-11T11:34:42-05:00] Out header: {"method":"highlight","args":null,"kwargs":{"options":{"outencoding":"utf-8"},"fd":7,"id":"XUMSFDPI","bytes":46}}'
log_message="[2014-02-11T11:34:42-05:00] Size in: 00000000000000000000000000100101 (38)"
log_message='[2014-02-11T11:34:42-05:00] In header: {"bytes": 169, "method": "highlight"}
'
log_message="[2014-02-11T11:34:42-05:00] Highlight in process."
log_message="[2014-02-11T11:34:42-05:00] Highlighting complete."
log_message="[2014-02-11T11:34:42-05:00] Killing pid: 95864. Reason: Exiting"
Just as an added documentation piece, here is the standard behavior:
require 'pygments'
ENV['MENTOS_LOG'] = "test.log"
code = "#!/usr/bin/ruby\nputs 'foo'"
output = Pygments.highlight(code)
puts output
# Logfile created on 2014-02-11 12:30:35 -0500 by logger.rb/44203
I, [2014-02-11 12:30 #11147] INFO -- : [2014-02-11T12:30:35-05:00] Starting pid 11193 with fd 10.
I, [2014-02-11 12:30 #11147] INFO -- : [2014-02-11T12:30:35-05:00] Out header: {"method":"highlight","args":null,"kwargs":{"options":{"outencoding":"utf-8"},"fd":10,"id":"MMHIKUET","bytes":46}}
I, [2014-02-11 12:30 #11147] INFO -- : [2014-02-11T12:30:35-05:00] Size in: 00000000000000000000000000100101 (38)
I, [2014-02-11 12:30 #11147] INFO -- : [2014-02-11T12:30:35-05:00] In header: {"bytes": 169, "method": "highlight"}
I, [2014-02-11 12:30 #11147] INFO -- : [2014-02-11T12:30:35-05:00] Highlight in process.
I, [2014-02-11 12:30 #11147] INFO -- : [2014-02-11T12:30:35-05:00] Highlighting complete.
I, [2014-02-11 12:30 #11147] INFO -- : [2014-02-11T12:30:35-05:00] Killing pid: 11193. Reason: Exiting
Closing this as "not needed"
Add an options hash to start and allow a logger to be specified by passing
:logger
through the options hash.For example: