Skip to content

Instantly share code, notes, and snippets.

@richmolj
Created June 21, 2013 16:48
Show Gist options
  • Save richmolj/5832570 to your computer and use it in GitHub Desktop.
Save richmolj/5832570 to your computer and use it in GitHub Desktop.
# when running cron jobs
module PutsOverride
def puts(*stmt)
if Configuration[:redirect_puts]
# write the stmt to custom log file for this cron
else
super(*stmt)
end
end
end
def redirect_puts_to_log_file
Configuration[:redirect_puts] = true
yield
Configuration[:redirect_puts] = false
end
def run_cron(name)
redirect_puts_to_log_file do
Rake::Task[name].invoke
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment