Todayish I learned

Make your own logger

17 Feb 2017

Sometimes it’s handy to have your own logger, so that you can log out just the bits that you’re interested in. Thanks to Jeanine from for this neat snippet

# Set up a custom logger.  View output in /log/my_error.log
class MyLogger < Logger
  def format_message(severity, timestamp, progname, msg)
    formatted_time = timestamp.strftime("%Y-%m-%d %H:%M:%S.") << timestamp.usec.to_s[0..2].rjust(3)
    "[%s] %s\n" % [formatted_time, msg]

logfile = + '/log/my_error.log','a')
logfile.sync = true
# TO USE:<stuff>) (or whatever level of debug info you want to use)