shitou's blog 
Home About Feed | MIX BOY 塌客

Tags "log"

19
Oct

发送异常到邮箱 by shitou

0

搞了ExceptionNotifier,觉得不好用,还是自己写吧

首先要配置好ActionMailer,戳我, 戳我, 戳我, 戳我

然后

#lib/exception_mail_notify.rb
class ExceptionMailNotify < ActionMailer::Base

  @@receivers = []
  @@subject_prefix = ''
  
  def self.receivers=(r)
    @@receivers = r
  end

  def self.subject_prefix=(s)
    @@subject_prefix = s
  end

  def self.receivers
    @@receivers
  end

  def app_exception_notify(recipient, body)
    from 'server@abc.com'
    recipients recipient
    subject "[#{@@subject_prefix}Exception] #{Time.now}"
    content_type "text/html"
    body body
  end
  
end

class ApplicationController < ActionController::Base

  protected

  def rescue_action(exception)
    if RAILS_ENV == 'production'
      error = "

" + exception.class.to_s + "

" + "

" + exception.message.inspect + "

" + exception.backtrace.join('
') ExceptionMailNotify.deliver_app_exception_notify ExceptionMailNotify.receivers.join(', '), error end super exception end end #app/controllers/application_controller.rb #收件人 ExceptionMailNotify.receivers = %w[a@abc.com b@abc.com] #邮件主题前缀 ExceptionMailNotify.subject_prefix = 'WWW '

 

你也可以写在其他controller里,对某一controller启作用

 

Tags: log

2009-10-19 16:34:57, 216 reviews

send to mailbox

Your email:

09
Oct

Rails日志分析工具 by shitou

0

Request-Log-Analyzer, 一个分析rails日志的工具,格式化输出结果,直接gem install request-log-analyzer; request-log-analyzer production.log;  就行了, 方便做性能分析使用,下面是测试的输出结果:

http://www.ccok.me/photo/image/48/medium/Screen_shot_2009-10-09_at_4.26.11_PM.png

 

Tags: log

2009-10-09 16:15:57, 251 reviews

send to mailbox

Your email:

Tags

U-ka saegusa IN db command Mai Kuraki Norah Jones log iPhoneException ACG Mac Safari objective-c CouchDB LVS AJAX debian 推荐 AMQP google mail bug gettext Erlang 北京 iptables 架构 tips mysql backup function 我看 postfix 监控 SEO cache Etag memcache thread 进程 线程 无锡 yield file column mixboy xml rss gems ruby shitou shell lighttpd 安全 csrf 公司 nginx linux 模块 apache webserver 朋友 大学 生活 尼古拉斯凯奇 movie 文件同步 笑笑 歌词 auto complete plugin rails music ubuntu blog

Category

  • iPhone[17]
  • Erlang[4]
  • google[8]
  • 生活[38]
  • 音乐[11]
  • 电影[11]
  • linux[20]
  • web server[6]
  • mail server[3]
  • cluster[1]
  • system manage[5]
  • ruby[18]
  • ruby on rails[27]
  • 开源[3]

Episode

  • iPhoneException
  • shell
  • thread
  • memcache

Recent Comments

  • comment6, http://www.freecodesource.com/user/pr...
  • comment7, viagra 100mg tablets, periwig, levitr...
  • comment5, prozac without prescription, :*), las...
  • comment2, viagra canada online, doors, lasix 20...
  • comment6, http://www.freecodesource.com/user/pr...
  • comment6, http://www.freecodesource.com/user/pr...
  • comment7, proscar flomax, <>], vicodin tablets,...
  • comment2, viagra medication, 2263, prilosec dia...
  • comment7, viagra sales australia, 401, oxycodon...
  • comment7, http://www.freecodesource.com/user/pr...

Popular Posts

  • MySQL Innodb备份
  • 准备开始学习Erlang了(恶狼, 二郎..)
  • Lighttpd配置参数
  • iPhone上的HelloWorld终于跑起来了
  • Etag和Expire

Recommended Posts

  • Mai Kuraki -永远より ながく
  • U-ka saegusa IN db Final Best
  • Heaven Can Wait - Charlotte Gainsbou
  • Ruby遍历MemCached的key
  • Norah Jones - The fall
  • 请记得仰望梦想的姿势
  • Shell: 统计MySQL InnoDB表的大小
  • Rails Benchmark
  • 发送异常到邮箱
  • I Miss Nobody
  • Music4u, Vol. 1
  • my macbook
  • Mai Kuraki-Beautiful
  • 10首最伤情英文歌曲精选
  • Mai Kuraki - PUZZLE/Revive

Friends' blogs

  • levy
  • sphance
  • andreas

Login

   注册

留言 查看留言

留言

   取消

留言 查看留言


Statistics

  • 访问次数: 51224
  • 今天访问: 88
  • 日志: 172
  • 评论: 121
  • 音乐: 9
  • 用户: 150


 

just DO NOT support IE

close