sinatra-request-logger 0.1.0 → 0.2.0
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/VERSION.yml +1 -1
- data/lib/sinatra/request-logger.rb +31 -39
- data/sinatra-request-logger.gemspec +54 -0
- metadata +3 -2
data/VERSION.yml
CHANGED
@@ -1,56 +1,48 @@
|
|
1
1
|
module Sinatra
|
2
2
|
module RequestLogger
|
3
3
|
def self.registered(app)
|
4
|
-
app.
|
5
|
-
app.
|
6
|
-
app.
|
7
|
-
settings.logger.info("#{env['sinatra.error'].class} (#{env['sinatra.error'].message})")
|
8
|
-
settings.logger.info(env['sinatra.error'].backtrace.join("\n"))
|
9
|
-
end
|
4
|
+
app.set :proxy_logger, ProxyLogger.new(app.logger)
|
5
|
+
app.use Rack::CommonLogger, app.proxy_logger
|
6
|
+
app.use ErrorLogger, app.proxy_logger
|
10
7
|
end
|
11
8
|
|
12
|
-
class
|
13
|
-
|
14
|
-
# lilith.local - - [07/Aug/2006 23:58:02] "GET / HTTP/1.1" 500 -
|
15
|
-
# %{%s - %s [%s] "%s %s%s %s" %d %s\n} %
|
16
|
-
FORMAT = %{%s - %s [%s] "%s %s%s %s" %d %s %0.4f}
|
17
|
-
|
18
|
-
def initialize(app, logger=nil)
|
19
|
-
@app = app
|
9
|
+
class ProxyLogger
|
10
|
+
def initialize(logger)
|
20
11
|
@logger = logger
|
21
12
|
end
|
22
13
|
|
23
|
-
def
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
14
|
+
def write(msg)
|
15
|
+
@logger.info(msg)
|
16
|
+
end
|
17
|
+
|
18
|
+
def flush
|
19
|
+
#nothing
|
29
20
|
end
|
30
21
|
|
31
|
-
|
22
|
+
def puts(msg)
|
23
|
+
if msg.is_a?(Array)
|
24
|
+
@logger.info(msg.map(&:chomp).join("\n"))
|
25
|
+
elsif msg.is_a?(String)
|
26
|
+
@logger.info(msg.chomp)
|
27
|
+
else
|
28
|
+
@logger.info(msg)
|
29
|
+
end
|
30
|
+
end
|
32
31
|
|
33
|
-
def
|
34
|
-
|
35
|
-
|
32
|
+
def method_missing(method, *args)
|
33
|
+
@logger.send(method, *args)
|
34
|
+
end
|
35
|
+
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
now.strftime("%d/%b/%Y %H:%M:%S"),
|
42
|
-
env["REQUEST_METHOD"],
|
43
|
-
env["PATH_INFO"],
|
44
|
-
env["QUERY_STRING"].empty? ? "" : "?"+env["QUERY_STRING"],
|
45
|
-
env["HTTP_VERSION"],
|
46
|
-
status.to_s[0..3],
|
47
|
-
length,
|
48
|
-
now - began_at ]
|
37
|
+
class ErrorLogger
|
38
|
+
def initialize(app, logger)
|
39
|
+
@app = app
|
40
|
+
@logger = logger
|
49
41
|
end
|
50
42
|
|
51
|
-
def
|
52
|
-
|
53
|
-
|
43
|
+
def call(env)
|
44
|
+
env['rack.errors'] = @logger
|
45
|
+
@app.call(env)
|
54
46
|
end
|
55
47
|
end
|
56
48
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{sinatra-request-logger}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Cyril Mougel"]
|
12
|
+
s.date = %q{2010-05-03}
|
13
|
+
s.description = %q{Log request and error on Logger send it by settings}
|
14
|
+
s.email = %q{cyril@yeastymobs.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION.yml",
|
26
|
+
"lib/sinatra/request-logger.rb",
|
27
|
+
"sinatra-request-logger.gemspec",
|
28
|
+
"test/helper.rb",
|
29
|
+
"test/test_sinatra-logger.rb"
|
30
|
+
]
|
31
|
+
s.homepage = %q{http://github.com/shingara/sinatra-request-logger}
|
32
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
33
|
+
s.require_paths = ["lib"]
|
34
|
+
s.rubygems_version = %q{1.3.6}
|
35
|
+
s.summary = %q{Log all request and error on Logger}
|
36
|
+
s.test_files = [
|
37
|
+
"test/helper.rb",
|
38
|
+
"test/test_sinatra-logger.rb"
|
39
|
+
]
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
43
|
+
s.specification_version = 3
|
44
|
+
|
45
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
46
|
+
s.add_runtime_dependency(%q<sinatra>, [">= 1.0.0"])
|
47
|
+
else
|
48
|
+
s.add_dependency(%q<sinatra>, [">= 1.0.0"])
|
49
|
+
end
|
50
|
+
else
|
51
|
+
s.add_dependency(%q<sinatra>, [">= 1.0.0"])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 2
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Cyril Mougel
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- Rakefile
|
49
49
|
- VERSION.yml
|
50
50
|
- lib/sinatra/request-logger.rb
|
51
|
+
- sinatra-request-logger.gemspec
|
51
52
|
- test/helper.rb
|
52
53
|
- test/test_sinatra-logger.rb
|
53
54
|
has_rdoc: true
|