Home  >  Article  >  Database  >  [ Ruby on Rails ] RedisLogger – a better redis log

[ Ruby on Rails ] RedisLogger – a better redis log

WBOY
WBOYOriginal
2016-06-07 16:29:181243browse

RedisLogger是一個Rails application專用的Redis logger,主要是利用Rails的ActiveSupport::LogSubscriber和ActiveSupport::Notifications去實做。 redis-rb其實有內建logger,Rails也可以輕易的使用,但在使用上,僅有每道指令的執行時間,略顯單薄,要判斷

RedisLogger是一個Rails application專用的Redis logger,主要是利用Rails的ActiveSupport::LogSubscriber和ActiveSupport::Notifications去實做。 redis-rb其實有內建logger,Rails也可以輕易的使用,但在使用上,僅有每道指令的執行時間,略顯單薄,要判斷每個action的redis執行時間還必須自己手動計算,感覺實在不太方便。所以就參考了Instrument Anything in Rails 3使用ActiveSupport::LogSubscriber和ActiveSupport::Notifications去觸發及計算執行時間,產生一個redis_logger.rb去overwrite redis-rb原本logger的行為,不但把每道Redis指令上色,並在action執行完成後計算Redis執行時間的總合。(如上圖所示) github: https://github.com/hellolucky/redis_logger enjoy it!
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn