footprint-log 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a5cf211c57f05def50f656c737306176effeb084
4
+ data.tar.gz: fa7ece836a764e7be0fa5ef81ab3e9358e0788df
5
+ SHA512:
6
+ metadata.gz: 24279ab4bcad20cc11ec2e505bd94066ae9cae8cabc9e2cc6198263d647c36bbf139aeec8175662ee7418aeca5eeea3fc0aba3f17aae5562960459db84cd2b76
7
+ data.tar.gz: ca646b801ac3d0313efa532c9d57ac4d63049feed5ed567d9898fa8ede431f5f9a796a55867c1af4e5944bc0009df2635fe1d350135fea34a61cd5a80cd479d6
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Puiu Ionut
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,114 @@
1
+ = Footprint (Beta)
2
+ Rack Application Logging Tools
3
+
4
+ {<img src="https://travis-ci.org/ipuiu/footprint-log.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/ipuiu/footprint-log]
5
+ {<img src="https://gemnasium.com/ipuiu/footprint-log.svg" alt="Dependency Status" />}[https://gemnasium.com/ipuiu/footprint-log]
6
+ {<img src="https://codeclimate.com/github/ipuiu/footprint-log/badges/gpa.svg" />}[https://codeclimate.com/github/ipuiu/footprint-log]
7
+ {<img src="https://coveralls.io/repos/ipuiu/footprint-log/badge.png?branch=master" alt="Coverage Status" />}[https://coveralls.io/r/ipuiu/footprint-log?branch=master]
8
+ {<img src="http://inch-ci.org/github/ipuiu/footprint-log.svg?branch=master" alt="Inline docs" />}[http://inch-ci.org/github/ipuiu/footprint-log]
9
+
10
+ == What is "Footprint" ?
11
+
12
+ Footprint was started by the need to have a simple and smart way to deal with the logs.
13
+
14
+ It is composed of:
15
+
16
+ require 'footprint/log' # some custom loggers.
17
+ require 'footprint/middleware' # middleware used to decorate Rack applications.
18
+
19
+ == How to use it ?
20
+
21
+ First you should add the gem to your Gemfile:
22
+
23
+ gem 'footprint-log'
24
+
25
+ === Basic Usage
26
+
27
+ Let's say that we don't care about what logger we use, and we just wish a logger method in our app that acts like a logger instance.
28
+
29
+ In that case we can do something like this:
30
+
31
+ require 'sinatra'
32
+ require 'footprint/middleware'
33
+
34
+ class MyApp < Sinatra
35
+
36
+ use Footprint::Middleware
37
+
38
+ get '/' do
39
+ logger.info 'I can use logger method inside my route!'
40
+ end
41
+
42
+ end
43
+
44
+ === Advanced Usage
45
+
46
+ Let's say that we care about what logger we use, and we also wish a logger method in our app that acts like a logger instance.
47
+
48
+ Let's assume we want to use a instance of the Logger class, initialized with log_device as STDOUT.
49
+
50
+ In that case we can do something like this:
51
+
52
+ require 'sinatra'
53
+ require 'footprint/middleware'
54
+
55
+ class MyApp < Sinatra
56
+
57
+ use Footprint::Middleware do
58
+ set Logger, STDOUT
59
+ end
60
+
61
+ get '/' do
62
+ logger.info 'I can use a instance of Logger class, initialized with STDOUT option by calling the logger method inside my route!'
63
+ end
64
+
65
+ end
66
+
67
+
68
+ Let's assume we want to use the following custom Logger class, initialized with log_device as STDOUT and level as 5.
69
+
70
+ class MyAwesomeLogger
71
+
72
+ attr_accesor :log_device, :level
73
+
74
+ def initialize log_device, level
75
+ @log_device = log_device
76
+ @level = level
77
+ end
78
+
79
+ end
80
+
81
+
82
+ In that case we can do something like this:
83
+
84
+ require 'sinatra'
85
+ require 'footprint/middleware'
86
+
87
+ class MyApp < Sinatra
88
+
89
+ use Footprint::Middleware do
90
+ set MyAwesomeLogger, [STDOUT,5]
91
+ end
92
+
93
+ get '/' do
94
+ logger.info 'I can use a instance of MyAwesomeLogger class, initialized with STDOUT, 5 option by calling the logger method inside my route!'
95
+ end
96
+
97
+ end
98
+
99
+
100
+ == Contributing to footprint
101
+
102
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
103
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
104
+ * Fork the project.
105
+ * Start a feature/bugfix branch.
106
+ * Commit and push until you are happy with your contribution.
107
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
108
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
109
+
110
+ == Copyright
111
+
112
+ Copyright (c) 2014 Puiu Ionut. See LICENSE.txt for
113
+ further details.
114
+
data/lib/footprint.rb ADDED
@@ -0,0 +1,9 @@
1
+ require_relative 'footprint/log'
2
+
3
+ module Footprint
4
+
5
+ attr_accessor :logger
6
+
7
+ end
8
+
9
+
@@ -0,0 +1,4 @@
1
+ require_relative 'log/basic'
2
+ require_relative 'log/error_file'
3
+ require_relative 'log/out_file'
4
+ require_relative 'log/gelf'
@@ -0,0 +1,17 @@
1
+ require 'logger'
2
+
3
+ module Footprint
4
+
5
+ module Log
6
+
7
+ class Basic < Logger
8
+
9
+ def initialize logdev = nil, shift_age = 0, shift_size = 1048576
10
+ super
11
+ end
12
+
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,17 @@
1
+ require_relative 'basic'
2
+
3
+ module Footprint
4
+
5
+ module Log
6
+
7
+ class ErrorFile < Basic
8
+
9
+ def write(message)
10
+ error message
11
+ end
12
+
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,13 @@
1
+ require 'gelf'
2
+
3
+ module Footprint
4
+
5
+ module Log
6
+
7
+ class Gelf < GELF::Logger
8
+
9
+ end
10
+
11
+ end
12
+
13
+ end
@@ -0,0 +1,17 @@
1
+ require_relative 'basic'
2
+
3
+ module Footprint
4
+
5
+ module Log
6
+
7
+ class OutFile < Basic
8
+
9
+ def write(message)
10
+ info message
11
+ end
12
+
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1 @@
1
+ require_relative 'middleware/logger'
@@ -0,0 +1,35 @@
1
+ require_relative '../log'
2
+
3
+
4
+ module Footprint
5
+
6
+ class Middleware
7
+
8
+ attr_accessor :app, :logger
9
+
10
+ def initialize(app, &block)
11
+
12
+ @app = app
13
+
14
+ set Footprint::Log::Basic, STDOUT
15
+
16
+ @app.class.send(:define_method, :logger,
17
+ Proc.new do
18
+ @env[:footprint_logger]
19
+ end)
20
+
21
+ self.instance_eval &block if block
22
+ end
23
+
24
+ def call(env)
25
+ env[:footprint_logger] = @logger
26
+ @app.call env
27
+ end
28
+
29
+ def set clazz, options=nil
30
+ @logger = clazz.send(:new, options)
31
+ end
32
+
33
+ end
34
+
35
+ end
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: footprint-log
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Puiu Ionut
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gelf
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: simplecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rack
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: jeweler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: coveralls
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Provides functionality to decorate Rack applications like Sinatra with
112
+ loggers.
113
+ email: ii.puiuionut@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files:
117
+ - LICENSE.txt
118
+ - README.rdoc
119
+ files:
120
+ - lib/footprint.rb
121
+ - lib/footprint/log.rb
122
+ - lib/footprint/log/basic.rb
123
+ - lib/footprint/log/error_file.rb
124
+ - lib/footprint/log/gelf.rb
125
+ - lib/footprint/log/out_file.rb
126
+ - lib/footprint/middleware.rb
127
+ - lib/footprint/middleware/logger.rb
128
+ - LICENSE.txt
129
+ - README.rdoc
130
+ homepage: http://github.com/ipuiu/footprint-log
131
+ licenses:
132
+ - MIT
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.0.3
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: Rack Application Log Decorator.
154
+ test_files: []