同步操作将从 Jim/exception_notification 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
This notifier sends notifications to a slack channel using the slack-notifier gem.
Just add the slack-notifier gem to your Gemfile
:
gem 'slack-notifier'
To configure it, you need to set at least the 'webhook_url' option, like this:
Rails.application.config.middleware.use ExceptionNotification::Rack,
email: {
email_prefix: '[PREFIX] ',
sender_address: %{"notifier" <notifier@example.com>},
exception_recipients: %w{exceptions@example.com}
},
slack: {
webhook_url: '[Your webhook url]',
channel: '#exceptions',
additional_parameters: {
icon_url: 'http://image.jpg',
mrkdwn: true
}
}
The slack notification will include any data saved under env['exception_notifier.exception_data']
.
An example of how to send the server name to Slack in Rails (put this code in application_controller.rb):
before_action :set_notification
def set_notification
request.env['exception_notifier.exception_data'] = { 'server' => request.env['SERVER_NAME'] }
# can be any key-value pairs
end
If you find this too verbose, you can determine to exclude certain information by doing the following:
Rails.application.config.middleware.use ExceptionNotification::Rack,
slack: {
webhook_url: '[Your webhook url]',
channel: '#exceptions',
additional_parameters: {
icon_url: 'http://image.jpg',
mrkdwn: true
},
ignore_data_if: lambda {|key, value|
"#{key}" == 'key_to_ignore' || value.is_a?(ClassToBeIgnored)
}
}
Any evaluation to true
will cause the key / value pair not be be sent along to Slack.
String, required
The Incoming WebHook URL on slack.
String, optional
Message will appear in this channel. Defaults to the channel you set as such on slack.
String, optional
Username of the bot. Defaults to the name you set as such on slack
String, optional
Custom hook name. See slack-notifier for more information. Default: 'incoming-webhook'
Hash of strings, optional
Contains additional payload for a message (e.g avatar, attachments, etc). See slack-notifier for more information.. Default: '{}'
Array of Hashes, optional
Contains additional fields that will be added to the attachement. See Slack documentation.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。