moro-logger_exception_format 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +31 -0
- data/Rakefile +110 -0
- data/lib/logger_exception_format.rb +19 -0
- data/rails/init.rb +5 -0
- data/spec/exception_format_logger_spec.rb +39 -0
- data/spec/spec_helper.rb +8 -0
- metadata +71 -0
data/README.rdoc
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
= logger_exception_format
|
2
|
+
|
3
|
+
let ActiveSupport::BufferedLogger log an exception detail.
|
4
|
+
|
5
|
+
|
6
|
+
== Installation
|
7
|
+
|
8
|
+
=== Archive Installation
|
9
|
+
|
10
|
+
rake install
|
11
|
+
|
12
|
+
=== Gem Installation
|
13
|
+
|
14
|
+
$ gem install logger_exception_format
|
15
|
+
|
16
|
+
and activate logger_exception_format in config/environment.rb
|
17
|
+
|
18
|
+
Example
|
19
|
+
=======
|
20
|
+
|
21
|
+
Rails.logger.debug(excepton) logged like below
|
22
|
+
|
23
|
+
|
24
|
+
[RuntimeError] An Error
|
25
|
+
/Users/moro/tmp/myapp/vendor/plugins/logger_exception_format/spec/exception_format_logger_spec.rb:17
|
26
|
+
/Users/moro/opt/ruby187/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:76:in `instance_eval'
|
27
|
+
/Users/moro/opt/ruby187/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:76:in `eval_each_fail_fast'
|
28
|
+
/Users/moro/opt/ruby187/lib/ruby/gems/1.8/gems/rspec-1.1.12/lib/spec/example/example_methods.rb:75:in `each'
|
29
|
+
|
30
|
+
Copyright (c) 2009 [name of plugin creator], released under the MIT license
|
31
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/packagetask'
|
5
|
+
require 'rake/gempackagetask'
|
6
|
+
require 'rake/rdoctask'
|
7
|
+
require 'rake/contrib/rubyforgepublisher'
|
8
|
+
require 'rake/contrib/sshpublisher'
|
9
|
+
require 'fileutils'
|
10
|
+
|
11
|
+
$:.unshift "lib"
|
12
|
+
require 'logger_exception_format'
|
13
|
+
|
14
|
+
require 'spec/rake/spectask'
|
15
|
+
include FileUtils
|
16
|
+
|
17
|
+
NAME = "logger_exception_format"
|
18
|
+
AUTHOR = "MOROHASHI Kyosuke"
|
19
|
+
EMAIL = "moronatural@gmail.com"
|
20
|
+
DESCRIPTION = "let ActiveSupport::BufferedLogger log an exception detail."
|
21
|
+
HOMEPATH = "http://github.com/moro/logger_exception_format/tree/master"
|
22
|
+
BIN_FILES = %w( )
|
23
|
+
|
24
|
+
VERS = LoggerExceptionFormat::Version
|
25
|
+
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
26
|
+
RDOC_OPTS = [
|
27
|
+
'--title', "#{NAME} documentation",
|
28
|
+
"--charset", "utf-8",
|
29
|
+
"--opname", "index.html",
|
30
|
+
"--line-numbers",
|
31
|
+
"--main", "README.rdoc",
|
32
|
+
"--inline-source",
|
33
|
+
]
|
34
|
+
|
35
|
+
task :default => [:test]
|
36
|
+
task :package => [:clean]
|
37
|
+
|
38
|
+
desc "Run all specs in spec directory"
|
39
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
40
|
+
t.spec_opts = %w[--colour --format progress --loadby --reverse]
|
41
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
42
|
+
end
|
43
|
+
|
44
|
+
spec = Gem::Specification.new do |s|
|
45
|
+
s.name = NAME
|
46
|
+
s.version = VERS
|
47
|
+
s.platform = Gem::Platform::RUBY
|
48
|
+
s.has_rdoc = true
|
49
|
+
s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
|
50
|
+
s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
|
51
|
+
s.summary = DESCRIPTION
|
52
|
+
s.description = DESCRIPTION
|
53
|
+
s.author = AUTHOR
|
54
|
+
s.email = EMAIL
|
55
|
+
s.homepage = HOMEPATH
|
56
|
+
s.executables = BIN_FILES
|
57
|
+
s.bindir = "bin" unless BIN_FILES.empty?
|
58
|
+
s.require_path = "lib"
|
59
|
+
s.test_files = Dir["spec/**/*_spec.rb"]
|
60
|
+
|
61
|
+
s.files = %w(README.rdoc ChangeLog Rakefile) +
|
62
|
+
Dir.glob("{bin,doc,test,lib,templates,generator,extras,website,script}/**/*") +
|
63
|
+
Dir.glob("spec/**/*.rb") +
|
64
|
+
Dir.glob("ext/**/*.{h,c,rb}") +
|
65
|
+
Dir.glob("examples/**/*.rb") +
|
66
|
+
Dir.glob("tools/*.rb") +
|
67
|
+
Dir.glob("rails/*.rb")
|
68
|
+
|
69
|
+
s.extensions = FileList["ext/**/extconf.rb"].to_a
|
70
|
+
end
|
71
|
+
|
72
|
+
Rake::GemPackageTask.new(spec) do |p|
|
73
|
+
p.need_tar = true
|
74
|
+
p.gem_spec = spec
|
75
|
+
end
|
76
|
+
|
77
|
+
task :install do
|
78
|
+
name = "#{NAME}-#{VERS}.gem"
|
79
|
+
sh %{rake package}
|
80
|
+
sh %{sudo gem install pkg/#{name}}
|
81
|
+
end
|
82
|
+
|
83
|
+
task :uninstall => [:clean] do
|
84
|
+
sh %{sudo gem uninstall #{NAME}}
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
Rake::RDocTask.new do |rdoc|
|
89
|
+
rdoc.rdoc_dir = 'html'
|
90
|
+
rdoc.options += RDOC_OPTS
|
91
|
+
rdoc.template = "resh"
|
92
|
+
#rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
93
|
+
if ENV['DOC_FILES']
|
94
|
+
rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
|
95
|
+
else
|
96
|
+
rdoc.rdoc_files.include('README.rdoc', 'ChangeLog')
|
97
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
98
|
+
rdoc.rdoc_files.include('ext/**/*.c')
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
desc 'Show information about the gem.'
|
103
|
+
task :debug_gem do
|
104
|
+
puts spec.to_ruby
|
105
|
+
end
|
106
|
+
|
107
|
+
desc 'Update gem spec'
|
108
|
+
task :gemspec do
|
109
|
+
open("#{NAME}.gemspec", 'w').write spec.to_ruby
|
110
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module LoggerExceptionFormat
|
2
|
+
Version = "0.0.2"
|
3
|
+
def self.included(base)
|
4
|
+
base.alias_method_chain :debug, :exception_format
|
5
|
+
end
|
6
|
+
|
7
|
+
def debug_with_exception_format(message=nil, programe=nil, &block)
|
8
|
+
return message unless debug?
|
9
|
+
if message.is_a? Exception
|
10
|
+
debug_without_exception_format do
|
11
|
+
lines = ["[#{message.class}] #{message.message}"]
|
12
|
+
lines << message.backtrace.map{|t| " #{t}" }
|
13
|
+
lines.join("\n")
|
14
|
+
end
|
15
|
+
else
|
16
|
+
debug_without_exception_format(message, programe, &block)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/rails/init.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# vim:set fileencoding=utf-8 filetype=ruby
|
3
|
+
# $KCODE = 'u'
|
4
|
+
|
5
|
+
require File.expand_path("spec_helper", File.dirname(__FILE__))
|
6
|
+
require 'active_support'
|
7
|
+
require 'active_support/buffered_logger'
|
8
|
+
|
9
|
+
describe LoggerExceptionFormat do
|
10
|
+
before :all do
|
11
|
+
ActiveSupport::BufferedLogger.send(:include, LoggerExceptionFormat)
|
12
|
+
end
|
13
|
+
|
14
|
+
before do
|
15
|
+
@logger = ActiveSupport::BufferedLogger.new(@buf = StringIO.new)
|
16
|
+
|
17
|
+
begin; raise "An Error" ; rescue => ex ; @exception = ex ; end
|
18
|
+
end
|
19
|
+
|
20
|
+
it do
|
21
|
+
@logger.debug(@exception)
|
22
|
+
|
23
|
+
@buf.string.split(/\n/).should have(@exception.backtrace.length + 1).items
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'first_line.should == "[RuntimeError] An Error"' do
|
27
|
+
@logger.debug(@exception)
|
28
|
+
|
29
|
+
first_line = @buf.string.split(/\n/).first.strip
|
30
|
+
first_line.should == "[RuntimeError] An Error"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "Ensure not break normal logging." do
|
34
|
+
@logger.debug("ensure not break normal logging.")
|
35
|
+
|
36
|
+
@buf.string.should == "ensure not break normal logging.\n"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: moro-logger_exception_format
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- MOROHASHI Kyosuke
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-02-28 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: let ActiveSupport::BufferedLogger log an exception detail.
|
17
|
+
email: moronatural@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.rdoc
|
24
|
+
- ChangeLog
|
25
|
+
files:
|
26
|
+
- README.rdoc
|
27
|
+
- ChangeLog
|
28
|
+
- Rakefile
|
29
|
+
- lib/logger_exception_format.rb
|
30
|
+
- spec/exception_format_logger_spec.rb
|
31
|
+
- spec/spec_helper.rb
|
32
|
+
- rails/init.rb
|
33
|
+
has_rdoc: true
|
34
|
+
homepage: http://github.com/moro/logger_exception_format/tree/master
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options:
|
37
|
+
- --title
|
38
|
+
- logger_exception_format documentation
|
39
|
+
- --charset
|
40
|
+
- utf-8
|
41
|
+
- --opname
|
42
|
+
- index.html
|
43
|
+
- --line-numbers
|
44
|
+
- --main
|
45
|
+
- README.rdoc
|
46
|
+
- --inline-source
|
47
|
+
- --exclude
|
48
|
+
- ^(examples|extras)/
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
version:
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.2.0
|
67
|
+
signing_key:
|
68
|
+
specification_version: 2
|
69
|
+
summary: let ActiveSupport::BufferedLogger log an exception detail.
|
70
|
+
test_files:
|
71
|
+
- spec/exception_format_logger_spec.rb
|