sinatra_logger 0.1.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 +7 -0
- data/LICENSE +22 -0
- data/README.md +18 -0
- data/lib/sinatra_logger.rb +2 -0
- data/lib/sinatra_logger/loggers.rb +30 -0
- data/lib/sinatra_logger/stdout_logger.rb +5 -0
- data/lib/sinatra_logger/version.rb +3 -0
- data/sinatra_logger.gemspec +17 -0
- metadata +50 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 20db498a9ecda21e52b88920a4bdf59147fdefa3
|
4
|
+
data.tar.gz: 1336299445f9c28b7526a2b5199d6573d2a790c6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d75e1bcac4fc46a43e9660fa9e8cf3f0b579cbf8c0541bba30c4ec2d141508838b72d757615b39e71d09aaea30e54235c13ee45d192d05160d006fb9c37912aa
|
7
|
+
data.tar.gz: 909ddcf47a2f6817e90108415bed878dc247b393e9a8a8690972976363ffac6a3284b1ebd1cb0df857c49e8b59277d9634c865f7e5203a8ed81abf5c80568163
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Al-waleed Shihadeh
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Sinatra Logger
|
2
|
+
The aim of this gem is to provide logging functionaly to Sinatra application
|
3
|
+
# Install
|
4
|
+
## In your Gemfile add:
|
5
|
+
~> gem "sinatra_logger", '0.1.0'
|
6
|
+
## Then run
|
7
|
+
~> bundle install
|
8
|
+
# Usage
|
9
|
+
## In application.rb
|
10
|
+
require 'sinatra_logger'
|
11
|
+
## Create Loggers
|
12
|
+
LOGGER = SinatraLogger::Loggers.file_logger("sinatra.log")
|
13
|
+
LOGGER = SinatraLogger::Loggers.stdout_logger
|
14
|
+
## In the Application class
|
15
|
+
configure :development, :production do
|
16
|
+
enable :logging
|
17
|
+
use Rack::CommonLogger, LOGGER
|
18
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "sinatra_logger/stdout_logger"
|
2
|
+
|
3
|
+
module SinatraLogger
|
4
|
+
class Loggers
|
5
|
+
def self.stdout_logger
|
6
|
+
STDOUT.sync = true
|
7
|
+
logger = StdoutLogger.new(STDOUT)
|
8
|
+
logger = ActiveSupport::TaggedLogging.new(logger) if defined?(ActiveSupport::TaggedLogging)
|
9
|
+
logger.level = StdoutLogger.const_get(log_level)
|
10
|
+
logger
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.file_logger(log_file_path)
|
14
|
+
file = File.new(log_file_path, 'a+')
|
15
|
+
file.sync = true
|
16
|
+
logger = Logger.new(file, shift_age)
|
17
|
+
logger.level = StdoutLogger.const_get(log_level)
|
18
|
+
logger
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.log_level
|
22
|
+
([(ENV['LOG_LEVEL']).to_s.upcase, "INFO"] & %w[DEBUG INFO WARN ERROR FATAL UNKNOWN]).compact.first
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.shift_age
|
26
|
+
([(ENV['SHIFT_AGE']).to_s.upcase, "daily"] & %w[daily weekly monthly]).compact.first
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path('../lib/sinatra_logger/version', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
|
5
|
+
gem.name = 'sinatra_logger'
|
6
|
+
gem.version = SinatraLogger::VERSION
|
7
|
+
gem.summary = "Sinatra Logger!"
|
8
|
+
gem.description = "Provides logining functionality for Sinatra Applications"
|
9
|
+
gem.authors = ["Al-waleed Shiahdeh"]
|
10
|
+
gem.email = 'wshiahdeh@live.com'
|
11
|
+
gem.homepage = 'https://github.com/wshihadeh/sinatra_logger'
|
12
|
+
|
13
|
+
gem.files = `git ls-files`.split("\n")
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.license = 'MIT'
|
16
|
+
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sinatra_logger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Al-waleed Shiahdeh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-18 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Provides logining functionality for Sinatra Applications
|
14
|
+
email: wshiahdeh@live.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- LICENSE
|
20
|
+
- README.md
|
21
|
+
- lib/sinatra_logger.rb
|
22
|
+
- lib/sinatra_logger/loggers.rb
|
23
|
+
- lib/sinatra_logger/stdout_logger.rb
|
24
|
+
- lib/sinatra_logger/version.rb
|
25
|
+
- sinatra_logger.gemspec
|
26
|
+
homepage: https://github.com/wshihadeh/sinatra_logger
|
27
|
+
licenses:
|
28
|
+
- MIT
|
29
|
+
metadata: {}
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
requirements: []
|
45
|
+
rubyforge_project:
|
46
|
+
rubygems_version: 2.4.6
|
47
|
+
signing_key:
|
48
|
+
specification_version: 4
|
49
|
+
summary: Sinatra Logger!
|
50
|
+
test_files: []
|