简体   繁体   中英

How to view print statements from Resque Workers in terminal Ruby

Using Redis and Resque to run background jobs. Currently trying to debug something that's going onto the queue. Problem is I cannot see the output of my print statements in terminal anywhere.

I tried to run workers with tail -f on the end, but getting rake errors each time I do that.

Anyone know how to view the output of Resque workers here?

As said by @Sachin you can use Rails logger ,

but Resque come up with own logging mechanism implemented over mono_logger

you can also do

Resque.logger. [ info | warn | error | debug | fatal ] are some of the log level feature that Resque Logging provide

Default Log is redirected to STDOUT (check here ) if you want to redirected to a file just change to a redirect it to a specific file in your code.

For more information on mono_logger refer the github readme

Hope this help

instead of using puts statement write to log with rails helpers

logger.debug "Person attributes hash: #{@person.attributes.inspect}"
logger.info "Processing the request..."
logger.fatal "Terminating application, raised unrecoverable error!!!"

you cannot see the result of puts statement and cant even use debugger in Resque.

Read about how to use logger in rails

http://guides.rubyonrails.org/debugging_rails_applications.html#sending-messages

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM