Module: Kernel
- Defined in:
- lib/jets/core_ext/kernel.rb
Overview
Works with jets/io.rb
Constant Summary collapse
- OVERRIDE_METHODS =
List from ruby-doc.org/core-2.5.1/Kernel.html Note, will lose pp format in the @io_buffer but looks like a lot of work to keep the pp format. Must override stdout which can be messy quick: www.ruby-forum.com/topic/43725
%w[ p pp print printf putc puts sprintf ]
- @@io_buffer =
[]
Instance Method Summary collapse
- #io_buffer ⇒ Object
-
#io_flush ⇒ Object
Note: Writing binary data to the log will crash the process with an error like this: jets/lib/jets/core_ext/kernel.rb:20:in ‘write’: “x89” from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError) Rescue and discard it to keep the process alive.
Instance Method Details
#io_buffer ⇒ Object
35 36 37 |
# File 'lib/jets/core_ext/kernel.rb', line 35 def io_buffer @@io_buffer end |
#io_flush ⇒ Object
Note: Writing binary data to the log will crash the process with an error like this:
jets/lib/jets/core_ext/kernel.rb:20:in `write': "\x89" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
Rescue and discard it to keep the process alive.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/jets/core_ext/kernel.rb', line 42 def io_flush chunk = @@io_buffer.join("\n") begin IO.write("/tmp/jets-output.log", chunk) # Writing to log with binary content will crash the process so rescuing it and writing an info message. rescue Encoding::UndefinedConversionError IO.write("/tmp/jets-output.log", "[BINARY DATA]") end @@io_buffer = [] end |