sinatra-logger 0.2.6 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1eb0c54730aa9b4e23c631855a98139a46b829c
4
- data.tar.gz: 5cc8b7bf5124bf99af66ebfdd37f0f1f01ead274
3
+ metadata.gz: 13b8a7744a40e59cc29fa00bdd787e7c75676539
4
+ data.tar.gz: f9b242bf47140f7a5063c2ee433f13e5c60037fc
5
5
  SHA512:
6
- metadata.gz: cebf2bd36ec73f7398d8fe0580287c0d3ec2e486c024d87b268c96c84054e7a19958cf403fb5159077c187178fdafcfe6a99500c29b4c2a1a42fd4d39aa13e38
7
- data.tar.gz: a08d3aca8d45ef6b08940975d07115205f990fefe7135d18c5240c0cc6c668c2e723fe616d8066c82cf0728375645f34221b278710ba491b075457e12cca8f33
6
+ metadata.gz: 8dd1d90c956096f9dc88dc765114233fc8ae94f6e4ff477862fabe00d506c659704f61f34fb1eff251229dcce43be1c693bcce5f1403f7d2075f603b566ec69e
7
+ data.tar.gz: 4e1d2297b34cd3ff4dd109431c58584c90b913928982c02d6415a0457b5f0dca99aada55fccc39dfa7350336bf4618dea80ba0e1e177f0729bdf0c97821f21a6
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 Yehya Abouelnaga
3
+ Copyright (c) 2016 Minodes GmbH
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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 'minodes-sinatra-logger'
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 minodes-sinatra-logger
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 "minodes/sinatra/logger"
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
@@ -0,0 +1,5 @@
1
+ module Sinatra
2
+ module Logger
3
+ VERSION = "0.3.0"
4
+ end
5
+ 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 'minodes/sinatra/logger/version'
4
+ require 'sinatra/logger/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "sinatra-logger"
8
- spec.version = Minodes::Sinatra::Logger::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.2.6
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-07-26 00:00:00.000000000 Z
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/minodes/sinatra/logger.rb
85
- - lib/minodes/sinatra/logger/version.rb
86
- - minodes-sinatra-logger.gemspec
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
@@ -1,7 +0,0 @@
1
- module Minodes
2
- module Sinatra
3
- module Logger
4
- VERSION = "0.2.6"
5
- end
6
- end
7
- end