biola_logs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6c88ba89e5b0b199c4a3aefb09177eaae64625e8
4
+ data.tar.gz: 21aedaa234cc64351544c6beee922066d2f0dd31
5
+ SHA512:
6
+ metadata.gz: 78d53ecc58bb570425e606fa806968c08efaf4f385f7a9be89b40f46750c7047c9f8f2f9477dfeddfdc32a0ff6ebb747c5fbb435c1cb42f6a086e6484b417cbf
7
+ data.tar.gz: eafc64f9f9541a096a3eecff8000c8b12a6c7dbb7de8ae741bbb3ac44afd2dcaeaf5be374dcd5bb5a2b3653c740fc7aef0cbdae89e9a8433e094886d57c6b80e
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2012 by Biola University
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,20 @@
1
+ Biola Logs
2
+ ==========
3
+
4
+ A simple gem to standardize log formatting across all our Rails apps
5
+
6
+ Usage
7
+ -----
8
+
9
+ Add the following to your `Gemfile`
10
+
11
+ ```ruby
12
+ gem 'biola_logs'
13
+ ```
14
+
15
+ And you're done.
16
+
17
+ License
18
+ -------
19
+
20
+ MIT
@@ -0,0 +1,8 @@
1
+ require 'lograge'
2
+ require 'biola_logs/generators'
3
+ require 'biola_logs/generators/base'
4
+ require 'biola_logs/generators/params'
5
+ require 'biola_logs/railtie'
6
+
7
+ module BiolaLogs
8
+ end
@@ -0,0 +1,15 @@
1
+ module BiolaLogs
2
+ module Generators
3
+ def self.all
4
+ self.constants.map(&self.method(:const_get)).grep(Class) - [Base]
5
+ end
6
+
7
+ def self.handler
8
+ Proc.new do |event|
9
+ self.all.each_with_object({}) do |klass, hash|
10
+ hash.merge! klass.new(event).to_hash
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ module BiolaLogs
2
+ module Generators
3
+ class Base
4
+ attr_reader :event
5
+
6
+ # event should quack like ActiveSupport::Notifications::Event
7
+ def initialize(event)
8
+ @event = event
9
+ end
10
+
11
+ def to_hash
12
+ raise ArgumentError, 'This method should be overridden in a subclass'
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,27 @@
1
+ module BiolaLogs
2
+ module Generators
3
+ class Params < Base
4
+ NON_QUERY_STRING_PARAMS = ['controller', 'action', 'id']
5
+ # We don't need form POST data in the logs since it can be very verbose.
6
+ SUPPORTED_HTTP_METHODS = ['GET']
7
+
8
+ def to_hash
9
+ if method_supported? && clean_params.any?
10
+ {params: clean_params.to_json}
11
+ else
12
+ {}
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ def clean_params
19
+ @clean_params ||= event.payload[:params].except(*NON_QUERY_STRING_PARAMS)
20
+ end
21
+
22
+ def method_supported?
23
+ SUPPORTED_HTTP_METHODS.include?(event.payload[:method])
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,8 @@
1
+ module BiolaLogs
2
+ class Railtie < Rails::Railtie
3
+ initializer :biola_logs, before: :lograge do |app|
4
+ config.lograge.enabled = true
5
+ config.lograge.custom_options = Generators.handler
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module BiolaLogs
2
+ VERSION = '0.1.0'
3
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: biola_logs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Adam Crownoble
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lograge
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.3'
27
+ description: Standardized, opinionated log formatting
28
+ email: adam.crownoble@biola.edu
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - MIT-LICENSE
34
+ - README.md
35
+ - lib/biola_logs.rb
36
+ - lib/biola_logs/generators.rb
37
+ - lib/biola_logs/generators/base.rb
38
+ - lib/biola_logs/generators/params.rb
39
+ - lib/biola_logs/railtie.rb
40
+ - lib/biola_logs/version.rb
41
+ homepage: https://github.com/biola/biola-logs
42
+ licenses:
43
+ - MIT
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.2.2
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: Standardized log formatter
65
+ test_files: []