安装 super_exception_notifier
gem 方式1:
sudo gem sources -a http://gemcutter.org
gem install super_exception_notifier
gem 方式2:
mkdir -p ~/src
cd ~/src
git clone git://github.com/pboling/exception_notification.git
cd exception_notification
gem build exception_notification.gemspec
sudo gem install super_exception_notification-2.0.0.gem # (Or whatever version gets built)
plugin git 方式:
./script/plugin install git://github.com/pboling/exception_notification.git
plugin svn 方式:
./script/plugin install http://super-exception-notifier.googlecode.com/svn/trunk/super_exception_notifier
application controller 中加入
class ApplicationController < ActionController::Base
include ExceptionNotifiable
...
end
配置exception_notifier
添加文件 exception_notifier.rb 到 config/initializers/exception_notifier.rb
exception_notifier.rb :
ExceptionNotifier.configure_exception_notifier do |config|
# If left empty web hooks will not be engaged
config[:web_hooks] = []
config[:app_name] = "[Project Name]"
# NOTE: THERE IS A BUG IN RAILS 2.3.3 which forces us to NOT use anything but a simple email address string for the sender address.
# https://rails.lighthouseapp.com/projects/8994/tickets/2340
# config[:sender_address] = %("#{(defined?(Rails) ? Rails.env : RAILS_ENV).capitalize} Error" <super.exception.notifier@example.com>)
config[:sender_address] = %("Project Name" <project_name.error@mail.project_name.com>)
config[:exception_recipients] = %w(project_name@googlegroups.com)
# Customize the subject line
#config[:subject_prepend] = "[#{(defined?(Rails) ? Rails.env : RAILS_ENV).capitalize} ERROR] "
config[:subject_prepend] = "[ProjectName ERROR] "
config[:subject_append] = " :("
# Include which sections of the exception email?
config[:sections] = %w(request session environment backtrace)
# Only use this gem to render, never email
#defaults to false - meaning by default it sends email. Setting true will cause it to only render the error pages, and NOT email.
config[:skip_local_notification] = true
# Example:
#config[:view_path] = 'app/views/error'
config[:view_path] = nil
# Error Notification will be sent if the HTTP response code for the error matches one of the following error codes
config[:notify_error_codes] = %W( 405 500 503 )
# Error Notification will be sent if the error class matches one of the following error error classes
config[:notify_error_classes] = %W( )
# What should we do for errors not listed?
config[:notify_other_errors] = true
# If you set this SEN will
config[:git_repo_path] = nil
config[:template_root] = "#{File.dirname(__FILE__)}/../views"
end
配置ActionMailer
可以加一个配置文件 config/config.yml
public:
smtp_server: 'mail.xxxx.com'
smtp_port: 25
smtp_domain: 'www.xxxx.com'
smtp_user_name: 'info@xxxx.com'
smtp_passwd: ""
smtp_authentication: 'login'
test:
smtp_server: 'mail.xxxx.com'
smtp_port: 25
smtp_domain: 'www.xxxx.com'
smtp_user_name: 'info@xxxx.com'
smtp_passwd: ""
smtp_authentication: 'login'
development:
smtp_server: 'mail.xxxx.com'
smtp_port: 25
smtp_domain: 'mail.xxxx.com'
smtp_user_name: 'info@xxxx.com'
smtp_passwd: ""
smtp_authentication: 'login'
production:
smtp_server: 'mail.xxxx.com'
smtp_port: 25
smtp_domain: 'mail.xxxx.com'
smtp_user_name: ''
smtp_passwd: ''
smtp_authentication: ''
加文件 20_mailer_config.rb
PUBLIC_CONFIG = YAML.load_file("#{RAILS_ROOT}/config/config.yml")['public']
PRIVATE_CONFIG = YAML.load_file("#{RAILS_ROOT}/config/config.yml")[RAILS_ENV]
CONFIG = PUBLIC_CONFIG.merge(PRIVATE_CONFIG || Hash.new)
ActionMailer::Base.smtp_settings = {
:address => CONFIG['smtp_server'],
:port => CONFIG['smtp_port'],
:domain => CONFIG['smtp_domain'],
:user_name => (CONFIG['smtp_authentication'].blank? ? nil : CONFIG['smtp_user_name']),
:password => (CONFIG['smtp_authentication'].blank? ? nil : CONFIG['smtp_passwd']),
:authentication => (CONFIG['smtp_authentication'].blank? ? nil : CONFIG['smtp_authentication'])
}
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
如果gem方式要加入gem 引用到 config/environment.rb
config.gem 'super_exception_notifier', :version => '~> 2.0.0', :lib => "exception_notifier"
如果要在本地测试要作下面三件事情:
1.服务要以production模式启动
2.config/initializers/exception_notifier.rb 中 config[:skip_local_notification] = false
3.在application controller 加 local_addresses.clear
分享到:
相关推荐
ExceptionNotification :: Shoryuken 这个Ruby宝石是宝石的扩展,并提供了一组通知器,用于在 worker中发生错误时发送通知。 如果将Shoryuken worker用作异步进程,这将很有用。 安装 将此行添加到您的应用程序的...
Android 源码:toast_and_notification,100ms延迟后,振动250ms,停止100ms后振动500ms,没有搞懂具体是干什么用的,本人非专业人士,发在源码爱好者,供喜欢的人研究。
NULL 博文链接:https://moyuan.iteye.com/blog/263869
FFXIV_Notification.mp3
pull_to_refresh_notification 语言:| 小部件以构建拉动以刷新效果。 样品4个糖果 样品5糖果 用代码刷新 刷新指标模式 enum RefreshIndicatorMode { drag, // Pointer is down. armed, // Dragged far enough ...
ESB应用Hello_World_Notification
30831_rad_studio_10.2.3_android_push_notification_patch.ZIP
Android_Notification详细解读
SEVEN Open Channel 文档,以及Push_Notification介绍
toast_and_notification,100ms延迟后,振动250ms,停止100ms后振动500ms。
python库。 资源全名:trytond_notification_email-4.8.4.tar.gz
资源来自pypi官网。 资源全名:djangoldp_notification-0.1.7.tar.gz
资源分类:Python库 所属语言:Python 资源全名:trytond_notification_email-4.8.1.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
python库。 资源全名:edc_notification-0.1.15-py3-none-any.whl
python库,解压后可用。 资源全名:edc_notification-0.1.5-py3-none-any.whl
资源来自pypi官网。 资源全名:edc_notification-0.1.5-py3-none-any.whl
资源分类:Python库 所属语言:Python 资源全名:djangoldp_notification-0.0.16.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
am_device_notification_callback 定义: typedef void(*am_device_notification_callback)(struct am_device_notification_callback_info *); 描述: 回调函数,当设备状态改变时由iTunesMobileDevice.dll回调 ...
python库,解压后可用。 资源全名:monasca_notification-3.0.0.0rc1-py3-none-any.whl