sinatra-logger 0.2.6 → 0.3.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.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +9 -2
- data/bin/console +1 -1
- data/lib/sinatra/logger.rb +51 -0
- data/lib/sinatra/logger/version.rb +5 -0
- data/{minodes-sinatra-logger.gemspec → sinatra-logger.gemspec} +2 -2
- metadata +5 -5
- data/lib/minodes/sinatra/logger.rb +0 -49
- data/lib/minodes/sinatra/logger/version.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13b8a7744a40e59cc29fa00bdd787e7c75676539
|
4
|
+
data.tar.gz: f9b242bf47140f7a5063c2ee433f13e5c60037fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dd1d90c956096f9dc88dc765114233fc8ae94f6e4ff477862fabe00d506c659704f61f34fb1eff251229dcce43be1c693bcce5f1403f7d2075f603b566ec69e
|
7
|
+
data.tar.gz: 4e1d2297b34cd3ff4dd109431c58584c90b913928982c02d6415a0457b5f0dca99aada55fccc39dfa7350336bf4618dea80ba0e1e177f0729bdf0c97821f21a6
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -25,7 +25,7 @@ Please, check the `SemanticLogger` (http://rocketjob.github.io/semantic_logger/)
|
|
25
25
|
Add this line to your application's Gemfile:
|
26
26
|
|
27
27
|
```ruby
|
28
|
-
gem '
|
28
|
+
gem 'sinatra-logger', '>= 0.2.6'
|
29
29
|
```
|
30
30
|
|
31
31
|
And then execute:
|
@@ -34,7 +34,7 @@ And then execute:
|
|
34
34
|
|
35
35
|
Or install it yourself as:
|
36
36
|
|
37
|
-
$ gem install
|
37
|
+
$ gem install sinatra-logger -v '>= 0.2.6'
|
38
38
|
|
39
39
|
### Usage
|
40
40
|
|
@@ -78,6 +78,13 @@ This gem is still in its beta phase. If you spot any errors, or propose some imp
|
|
78
78
|
|
79
79
|
Bug reports and pull requests are welcome on GitHub at https://github.com/minodes/sinatra-logger. We would love to see your suggestions, fixes or improvements.
|
80
80
|
|
81
|
+
## Version Updates
|
82
|
+
* 0.3.0
|
83
|
+
- Add support for ActiveRecord logging
|
84
|
+
* 0.2.6
|
85
|
+
- Sinatra Access Logging
|
86
|
+
- Sinatra Error Logging
|
87
|
+
- Normal Logging functionality (`logger.info`, ...)
|
81
88
|
|
82
89
|
## License
|
83
90
|
|
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "bundler/setup"
|
4
|
-
require "
|
4
|
+
require "sinatra/logger"
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "sinatra/logger/version"
|
2
|
+
require "sinatra"
|
3
|
+
require "rack"
|
4
|
+
require 'rack/body_proxy'
|
5
|
+
require 'rack/utils'
|
6
|
+
require "semantic_logger"
|
7
|
+
require "logger"
|
8
|
+
|
9
|
+
module Sinatra
|
10
|
+
class ErrorLogger
|
11
|
+
def puts(msg)
|
12
|
+
SemanticLogger["Error"].error msg
|
13
|
+
end
|
14
|
+
|
15
|
+
def flush
|
16
|
+
SemanticLogger.flush
|
17
|
+
end
|
18
|
+
|
19
|
+
def <<(msg)
|
20
|
+
# To satisfy test calls. This function is available on "Logger" class by default.
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module Logger
|
25
|
+
::Sinatra::Base.class_eval do
|
26
|
+
def self.logger(config)
|
27
|
+
if config[:filename].nil?
|
28
|
+
raise "Sinatra::Logger -- File name is not specified. Please, set `filename` in the configuration block!"
|
29
|
+
end
|
30
|
+
|
31
|
+
config[:level] ||= :trace
|
32
|
+
::SemanticLogger.default_level = config[:level]
|
33
|
+
|
34
|
+
set :logging, true
|
35
|
+
use ::Rack::CommonLogger, ::SemanticLogger["Access"]
|
36
|
+
|
37
|
+
# ActiveRecord Logger
|
38
|
+
ActiveRecord::Base.logger = ::SemanticLogger["SQL"]
|
39
|
+
|
40
|
+
::Sinatra::Base.before do
|
41
|
+
::SemanticLogger.default_level = config[:level]
|
42
|
+
::SemanticLogger.appenders.each { |a| ::SemanticLogger.remove_appender(a) }
|
43
|
+
::SemanticLogger.add_appender(file_name: config[:filename], formatter: :color)
|
44
|
+
|
45
|
+
env["rack.errors"] = ::Sinatra::ErrorLogger.new
|
46
|
+
env["rack.logger"] = ::SemanticLogger[self.class.name]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require '
|
4
|
+
require 'sinatra/logger/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "sinatra-logger"
|
8
|
-
spec.version =
|
8
|
+
spec.version = Sinatra::Logger::VERSION
|
9
9
|
spec.authors = ["Yehya Abouelnaga"]
|
10
10
|
spec.email = ["yehya.abouelnaga@minodes.com"]
|
11
11
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yehya Abouelnaga
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: semantic_logger
|
@@ -81,9 +81,9 @@ files:
|
|
81
81
|
- Rakefile
|
82
82
|
- bin/console
|
83
83
|
- bin/setup
|
84
|
-
- lib/
|
85
|
-
- lib/
|
86
|
-
-
|
84
|
+
- lib/sinatra/logger.rb
|
85
|
+
- lib/sinatra/logger/version.rb
|
86
|
+
- sinatra-logger.gemspec
|
87
87
|
homepage: https://github.com/minodes/sinatra-logger
|
88
88
|
licenses:
|
89
89
|
- MIT
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require "minodes/sinatra/logger/version"
|
2
|
-
require "sinatra"
|
3
|
-
require "rack"
|
4
|
-
require 'rack/body_proxy'
|
5
|
-
require 'rack/utils'
|
6
|
-
require "semantic_logger"
|
7
|
-
require "logger"
|
8
|
-
|
9
|
-
module Minodes
|
10
|
-
module Sinatra
|
11
|
-
class ErrorLogger
|
12
|
-
def puts(msg)
|
13
|
-
SemanticLogger["Error"].error msg
|
14
|
-
end
|
15
|
-
|
16
|
-
def flush
|
17
|
-
SemanticLogger.flush
|
18
|
-
end
|
19
|
-
|
20
|
-
def <<(msg)
|
21
|
-
# To satisfy test calls. This function is available on "Logger" class by default.
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
module Logger
|
26
|
-
::Sinatra::Base.class_eval do
|
27
|
-
def self.logger(config)
|
28
|
-
if config[:filename].nil?
|
29
|
-
raise "Minodes::Sinatra::Logger -- File name is not specified. Please, set `file_name` in the configuration block!"
|
30
|
-
end
|
31
|
-
|
32
|
-
config[:level] ||= :trace
|
33
|
-
|
34
|
-
set :logging, true
|
35
|
-
use ::Rack::CommonLogger, ::SemanticLogger["Access"]
|
36
|
-
|
37
|
-
::Sinatra::Base.before do
|
38
|
-
::SemanticLogger.default_level = config[:level]
|
39
|
-
::SemanticLogger.appenders.each { |a| ::SemanticLogger.remove_appender(a) }
|
40
|
-
::SemanticLogger.add_appender(file_name: config[:filename], formatter: :color)
|
41
|
-
|
42
|
-
env["rack.errors"] = ::Minodes::Sinatra::ErrorLogger.new
|
43
|
-
env["rack.logger"] = ::SemanticLogger[self.class.name]
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|