Skip to content

Commit eb54ede

Browse files
committed
Added redmine exception handler.
0 parents  commit eb54ede

File tree

101 files changed

+12153
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+12153
-0
lines changed

COPYRIGHT.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Redmine Exception Handler plugin will allow Redmine to send emails when an
2+
exception or error occurs.
3+
4+
Copyright (C) 2008 Little Stream Software
5+
6+
This program is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU General Public License
8+
as published by the Free Software Foundation; either version 2
9+
of the License, or (at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

CREDITS.rdoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Thanks go to the following people for patches and contributions:
2+
3+
* Eric Davis of Little Stream Software - Project Maintainer
4+
* Jamis Buck - Creater of the Exception Notifier Plugin for Rails

GPL.txt

Lines changed: 339 additions & 0 deletions
Large diffs are not rendered by default.

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
gem 'tinder', '1.9.1'
2+
gem 'actionmailer', '>= 3.0.4'
3+
gem 'exception_notification', '3.0.1'

README.rdoc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
= Redmine Exception Handler plugin
2+
3+
The Redmine Exception Handler plugin will allow Redmine to send emails when an exception or error occurs.
4+
5+
== Features
6+
7+
* Allows configuration of recipients, sender address, and subject line without restarting the web server
8+
* Email contains a stack trace and full environment dump that can be used to reproduce the issue
9+
* Test controller to test the system settings
10+
11+
== Install
12+
13+
1. Follow the Redmine plugin installation steps at: http://www.redmine.org/wiki/redmine/Plugins Make sure the plugin is installed to +plugins/redmine_exception_handler+
14+
2. Run bundle install
15+
3. Login to Redmine as an Administrator
16+
4. Setup your mail settings in the Plugin settings panel
17+
5. Test your settings using the "Test settings" link
18+
19+
== License
20+
21+
This plugin is licensed under the GNU GPL v2. See COPYRIGHT.txt and GPL.txt for details.
22+
23+
== Help
24+
25+
If you need help you can contact the maintainer at his email address (See CREDITS) or create an issue in the {Bug Tracker}:[https://projects.littlestreamsoftware.com/projects/show/redmine-exception]

Rakefile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env ruby
2+
require "fileutils"
3+
4+
Dir[File.expand_path(File.dirname(__FILE__)) + "/lib/tasks/**/*.rake"].sort.each { |ext| load ext }
5+
6+
# Modifided from the RSpec on Rails plugins
7+
PLUGIN_ROOT = File.expand_path(File.dirname(__FILE__))
8+
REDMINE_APP = File.expand_path(File.dirname(__FILE__) + '/../../../app')
9+
REDMINE_LIB = File.expand_path(File.dirname(__FILE__) + '/../../../lib')
10+
11+
# In rails 1.2, plugins aren't available in the path until they're loaded.
12+
# Check to see if the rspec plugin is installed first and require
13+
# it if it is. If not, use the gem version.
14+
rspec_base = File.expand_path(File.dirname(__FILE__) + '/../rspec/lib')
15+
$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
16+
17+
require 'rake'
18+
require 'rake/clean'
19+
require 'rake/rdoctask'
20+
21+
PROJECT_NAME = 'redmine_exception_handler_plugin'
22+
REDMINE_PROJECT_NAME = 'redmine-exception'
23+
CLEAN.include('**/semantic.cache', "**/#{PROJECT_NAME}.zip", "**/#{PROJECT_NAME}.tar.gz")
24+
25+
# No Database needed
26+
spec_prereq = :noop
27+
task :noop do
28+
end
29+
30+
task :default => :spec
31+
32+
desc 'Generate documentation for the plugin.'
33+
Rake::RDocTask.new(:doc) do |rdoc|
34+
rdoc.rdoc_dir = 'doc'
35+
rdoc.title = PROJECT_NAME
36+
rdoc.options << '--line-numbers' << '--inline-source'
37+
rdoc.rdoc_files.include('README.rdoc')
38+
rdoc.rdoc_files.include('lib/**/*.rb')
39+
rdoc.rdoc_files.include('app/**/*.rb')
40+
end
41+
42+
43+
namespace :release do
44+
desc "Create a zip archive"
45+
task :zip => [:clean] do
46+
sh "git archive --format=zip --prefix=#{PROJECT_NAME}/ HEAD > #{PROJECT_NAME}.zip"
47+
end
48+
49+
desc "Create a tarball archive"
50+
task :tarball => [:clean] do
51+
sh "git archive --format=tar --prefix=#{PROJECT_NAME}/ HEAD | gzip > #{PROJECT_NAME}.tar.gz"
52+
end
53+
54+
desc 'Uploads project documentation'
55+
task :upload_doc => ['spec:rcov', :doc, 'spec:htmldoc'] do |t|
56+
# TODO: Get rdoc working without frames
57+
`scp -r doc/ dev.littlestreamsoftware.com:/home/websites/projects.littlestreamsoftware.com/shared/embedded_docs/#{REDMINE_PROJECT_NAME}/doc`
58+
`scp -r coverage/ dev.littlestreamsoftware.com:/home/websites/projects.littlestreamsoftware.com/shared/embedded_docs/#{REDMINE_PROJECT_NAME}/coverage`
59+
end
60+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class ExampleExceptionController < ApplicationController
2+
unloadable
3+
4+
def index
5+
raise Exception, 'Example exception'
6+
end
7+
end
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<p>
2+
<label><%= l(:exception_handler_label_email_recipients) %></label><br /><label><small><%= l(:exception_handler_label_separate_multiple_emails_with_commas) %></small></label><%= text_area_tag 'settings[exception_handler_recipients]', @settings['exception_handler_recipients'], :rows => 5, :cols => 60 %>
3+
</p>
4+
5+
<p>
6+
<label><%= l(:exception_handler_label_sender_address)%></label><%= text_field_tag 'settings[exception_handler_sender_address]', @settings['exception_handler_sender_address'], :size => 60 %>
7+
</p>
8+
9+
<p>
10+
<label><%= l(:exception_handler_label_subject_prefix)%></label><%= text_field_tag 'settings[exception_handler_prefix]', @settings['exception_handler_prefix'], :size => 15 %>
11+
</p>
12+
13+
<p>
14+
<label><%= l(:exception_handler_label_email_format)%></label><%= select_tag 'settings[exception_handler_email_format]', options_for_select(['text', 'html'], @settings['exception_handler_email_format']) %>
15+
</p>
16+
17+
<p>
18+
<%= link_to l(:exception_handler_label_test_settings), { :controller => 'example_exception'}, :target => '_blank' %> <%= l(:exception_handler_label_will_open_in_a_new_window) %>
19+
</p>

config/locales/en.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
en:
2+
exception_handler_label_email_recipients: "Email recipients"
3+
exception_handler_label_separate_multiple_emails_with_commas: "Separate multiple email addresses with commas"
4+
exception_handler_label_sender_address: "Sender address"
5+
exception_handler_label_subject_prefix: "Subject prefix"
6+
exception_handler_label_email_format: "Email format"
7+
exception_handler_label_test_settings: "Test Settings by triggering a fake exception"
8+
exception_handler_label_will_open_in_a_new_window: "(will open in a new window)"

config/locales/ru.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ru:
2+
exception_handler_label_email_recipients: "Получатели письма"
3+
exception_handler_label_separate_multiple_emails_with_commas: "Разделяйте e-mail'ы запятой"
4+
exception_handler_label_sender_address: "Адрес отправителя"
5+
exception_handler_label_subject_prefix: "Префикс темы письма"
6+
exception_handler_label_email_format: "E-mail формате"
7+
exception_handler_label_test_settings: "Проверить настройки вызовом тестовой ошибки"
8+
exception_handler_label_will_open_in_a_new_window: "(откроется в новом окне)"

config/routes.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
RedmineApp::Application.routes.draw do
2+
get '/example_exception' => 'example_exception#index'
3+
end

init.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require 'redmine'
2+
3+
# Dir[File.join(Redmine::Plugin.directory,'redmine_exception_handler','vendor','plugins','*')].each do |dir|
4+
# path = File.join(dir, 'lib')
5+
# $LOAD_PATH << path
6+
# ActiveSupport::Dependencies.autoload_paths << path
7+
# end
8+
9+
Redmine::Plugin.register :redmine_exception_handler do
10+
name 'Redmine Exception Handler plugin'
11+
author 'Eric Davis'
12+
description 'Send emails when exceptions occur in Redmine.'
13+
version '1.0.0'
14+
requires_redmine :version_or_higher => '2.0.0'
15+
16+
settings :default => {
17+
'exception_handler_recipients' => '[email protected]',
18+
'exception_handler_sender_address' => 'RDQ3 Exception <[email protected]>',
19+
'exception_handler_prefix' => "[RDQ3 #{Rails.env}]",
20+
'exception_handler_email_format' => 'text'
21+
}, :partial => 'settings/exception_handler_settings'
22+
23+
end
24+
25+
require_dependency 'exception_notification'
26+
ExceptionNotifier::Notifier.send(:include, ExceptionHandler::RedmineNotifierPatch)
27+
28+
RedmineApp::Application.config.middleware.use ExceptionNotifier
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module ExceptionHandler
2+
module RedmineNotifierPatch
3+
def self.included(target)
4+
target.send(:include, InstanceMethods)
5+
target.send(:alias_method_chain, :exception_notification, :database)
6+
end
7+
8+
module InstanceMethods
9+
def exception_notification_with_database(env, exception, options = {})
10+
settings = Setting.plugin_redmine_exception_handler
11+
options[:exception_recipients] = settings['exception_handler_recipients'].split(',').map(&:strip)
12+
options[:sender_address] = settings['exception_handler_sender_address']
13+
options[:email_prefix] = settings['exception_handler_prefix']
14+
options[:email_format] = (settings['exception_handler_email_format'] || 'text').to_sym
15+
exception_notification_without_database(env, exception, options)
16+
end
17+
18+
end
19+
20+
end
21+
end

test/test_helper.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Load the normal Rails helper
2+
require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper')
3+
4+
# Ensure that we are using the temporary fixture path
5+
Engines::Testing.set_fixture_path

vendor/plugins/exception_notification/.gemtest

Whitespace-only changes.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
== 3.0.0
2+
3+
* enhancements
4+
* Campfire integration
5+
* Support fot HTML notifications (by @Xenofex)
6+
* Be able to override SMTP settings (by @piglop and @Macint)
7+
8+
* bug fixes
9+
* Fix encoding issues
10+
* Allow default sections to be overridden (by @jfarmer)
11+
* Don't automatically deliver background notifications
12+
13+
== 2.6.1
14+
15+
* bug fixes
16+
* Fix finding custom sections on Background notifications. Fixes [#68]
17+
18+
== 2.6.0
19+
20+
* enhancements
21+
* Avoid raising exception on dev mode
22+
* Add ignore_if option to avoid sending certain notifications.
23+
* Add normalize_subject option to remove numbers from email so that they thread (by @jjb)
24+
* Allow the user to provide a custom message and hash of data (by @jjb)
25+
* Add support for configurable background sections and a data partial (by @jeffrafter)
26+
* Include timestamp of exception in notification body
27+
* Add support for rack based session management (by @phoet)
28+
* Add ignore_crawlers option to ignore exceptions generated by crawlers
29+
* Add verbode_subject option to exclude exception message from subject (by @amishyn)
30+
31+
* bug fixes
32+
* Correctly set view path at the right time so that new sections are properly available (by @scrozier)
33+
* Fix handling exceptions with no backtrace
34+
* Fix issue on Solaris with hostname (by @bluescripts)
35+
* Ensure exceptions in view templates doesn't cause problems, allowing the notification to be sent anyway (by @sce)
36+
37+
== 2.5.1
38+
39+
* bug fixes
40+
* Fix lib references on gemspec
41+
42+
== 2.5.0
43+
44+
* enhancements
45+
* Add Background Notifications
46+
47+
* bug fixes
48+
* Filter session_id on secure requests
49+
50+
== 2.4.1
51+
52+
* enhancements
53+
* Use values set for the middleware as defaults
54+
55+
* bug fixes
56+
* Avoid sending emails with large subjects
57+
* Avoid having to add 'require' option on gem configuration
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# How to contribute
2+
3+
We love your contribution, for it's essential for making ExceptionNotification greater every day.
4+
In order to keep it as easy as possible to contribute changes, here are a few guidelines that we
5+
need contributors to follow:
6+
7+
## First of all
8+
9+
* Check if the issue you're going to submit isn't already submitted in
10+
the [Issues](https://github.com/smartinez87/exception_notification/issues) page.
11+
12+
## Issues
13+
14+
* Submit a ticket for your issue, assuming one does not already exist.
15+
* The issue must:
16+
* Clearly describe the problem including steps to reproduce when it is a bug.
17+
* Also include all the information you can to make it easier for us to reproduce it,
18+
like OS version, gem versions, etc...
19+
* Even better, provide a failing test case for it.
20+
21+
## Pull Requests
22+
23+
If you've gone the extra mile and have a patch that fixes the issue, you
24+
should submit a Pull Request!
25+
26+
* Fork the repo on Github.
27+
* Create a topic branch from where you want to base your work.
28+
* Add a test for your change. Only refactoring and documentation changes
29+
require no new tests. If you are adding functionality or fixing a bug,
30+
we need a test!
31+
* Run _all_ the tests to assure nothine else was broken. We only take pull requests with passing tests.
32+
* Check for unnecessary whitespace with `git diff --check` before committing.
33+
* Push to your fork and submit a pull request.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source "http://rubygems.org"
2+
3+
gemspec

0 commit comments

Comments
 (0)