class Logger
def reopen(logdev = nil)
# "E, [2022-05-12T14:23:05.847241 #22428] ERROR -- : three\n"]
# "E, [2022-05-12T14:21:27.596726 #22428] ERROR -- : one\n",
# ["# Logfile created on 2022-05-12 14:21:19 -0500 by logger.rb/v1.5.0\n",
# =>
File.readlines('t.log')
logger.close
logger.add(Logger::ERROR, 'three')
logger.reopen
logger.add(Logger::ERROR, 'two') # Prints 'log writing failed. closed stream'
logger.close
logger.add(Logger::ERROR, 'one')
logger = Logger.new('t.log')
Example:
opens the stream for append.
(usually $stdout, $stderr, or an open File object),
- If +logdev+ is an IO stream
- If +logdev+ is a filepath, opens the indicated file for append.
- If +logdev+ is +nil+, reopens the current output stream.
Sets the logger's output stream:
def reopen(logdev = nil) @logdev&.reopen(logdev) self end