rails_better_logger 0.2.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: ab336ab3219beacd7fe884a7ea62f6019091f49d
4
+ data.tar.gz: f7d328b49a7da6d5a16a13596f9d8ff8a3eaee06
5
+ SHA512:
6
+ metadata.gz: 83b5f81982cd27f42817eceb7e5fc72329944b8efe074de27b8a4e86f13857556bcda2dd1f81a00243b0fa9d8c2d70c5f3de9fd625a9f78e66e649f6c39e7fb0
7
+ data.tar.gz: 465822ebd3f978af01f31fe629fe136db1476532003ff3e070208822c008ce91a46447d159319f9c8c8b3d3b8224fa4bbfbd0febac7e42108e28e94c283a3f54
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Billy.Zheng
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,72 @@
1
+ # RailsBetterLogger [![Build Status](https://travis-ci.org/zw963/rails_better_logger.svg?branch=master)](https://travis-ci.org/zw963/rails_better_logger) [![Gem Version](https://badge.fury.io/rb/rails_better_logger.svg)](http://badge.fury.io/rb/rails_better_logger)
2
+
3
+ It just original rails logger, you don't miss anything, just better.
4
+
5
+ ## Getting Started
6
+
7
+ Install via Rubygems
8
+
9
+ $ gem install rails_better_logger
10
+
11
+ And then you could make this gem applied to all your's rails project
12
+ with just settings one environment variable in you $HOME startup script.
13
+
14
+ e.g. any of .bashrc/.profile/.bash_profie, setting this:
15
+
16
+ ```sh
17
+ export $RUBYOPT=-rrails_better_logger
18
+ ```
19
+
20
+ Or ...
21
+
22
+ Add to your project Gemfile
23
+
24
+ group :development do
25
+ gem 'rails_better_logger'
26
+ end
27
+
28
+ ## SnapShot
29
+
30
+ 1. Highlight any request and controller action, with params.
31
+
32
+ ![File](rails_better_logger1.png)
33
+
34
+ 2. Highlight `UPDATE/INSERT/DELETE` SQL query.
35
+
36
+ ![File](rails_better_logger2.png)
37
+
38
+ 3. SQL query positional parameter always be print to a new line.
39
+ (make query and data seperate, more clearly)
40
+
41
+ ![File](rails_better_logger3.png)
42
+
43
+ 4. Highlight slow rendered views. (great than 99 ms)
44
+
45
+ ![File](rails_better_logger4.png)
46
+
47
+ ## Support
48
+
49
+ * Rails 4+, should support Rails 3 too, issues welcome.
50
+
51
+ ## Advise
52
+ * Any advise is welcome, just make this gem better.
53
+
54
+ ## TODO
55
+
56
+ * Background highlight for any Exception.
57
+ * Make color can be configure.
58
+ ## Contributing
59
+
60
+ * [Bug reports](https://github.com/zw963/rails_better_logger/issues)
61
+ * [Source](https://github.com/zw963/rails_better_logger)
62
+ * Patches:
63
+ * Fork on Github.
64
+ * Run `gem install --dev rails_better_logger` or `bundle`.
65
+ * Create your feature branch: `git checkout -b my-new-feature`.
66
+ * Commit your changes: `git commit -am 'Add some feature'`.
67
+ * Push to the branch: `git push origin my-new-feature`.
68
+ * Send a pull request :D.
69
+
70
+ ## license
71
+
72
+ Released under the MIT license, See [LICENSE](https://github.com/zw963/rails_better_logger/blob/master/LICENSE) for details.
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+
4
+ module RailsBetterLogger
5
+ VERSION = [0, 2, 0]
6
+
7
+ class << VERSION
8
+ def to_s
9
+ join(?.)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+
4
+ require 'rails_better_logger/version'
5
+ require 'active_support/log_subscriber'
6
+ require 'active_support/lazy_load_hooks'
7
+
8
+ ActiveSupport.on_load(:after_initialize) do |_app|
9
+ module ActionView
10
+ class LogSubscriber < ActiveSupport::LogSubscriber
11
+ def info(progname=nil, &block)
12
+ log = block_given? ? block.call : progname
13
+
14
+ better_log = log
15
+ .sub(/([0-9]{3,})(.[0-9])?ms/, '\1\2ms')
16
+
17
+ if block_given?
18
+ super(progname) { better_log }
19
+ else
20
+ super(better_log)
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ module ActiveSupport
27
+ class Logger
28
+ def info(progname=nil, &block)
29
+ http_verb = Regexp.union(%w[GET POST PUT PATCH DELETE])
30
+ log = block_given? ? block.call : progname
31
+
32
+ better_log = log
33
+ .sub(/(#{http_verb} ".+")/, '\1')
34
+
35
+ if block_given?
36
+ super(progname) { better_log }
37
+ else
38
+ super(better_log)
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ module ActionController
45
+ class LogSubscriber < ActiveSupport::LogSubscriber
46
+ def info(progname=nil, &block)
47
+ log = block_given? ? block.call : progname
48
+
49
+ better_log = log
50
+ .sub(/{(.+)}/, '{\1}')
51
+ .sub(/Processing by ([\w#]+) as ([A-Z]+)/, 'Processing by \1 as \2')
52
+
53
+ if block_given?
54
+ super(progname) { better_log }
55
+ else
56
+ super(better_log)
57
+ end
58
+ end
59
+ alias_method :error, :info
60
+ end
61
+ end
62
+
63
+ module ActiveRecord
64
+ class LogSubscriber < ActiveSupport::LogSubscriber
65
+ def debug(progname=nil, &block)
66
+ sql_verb = Regexp.union(%w[UPDATE INSERT DELETE])
67
+ log = block_given? ? block.call : progname
68
+
69
+ better_log = log
70
+ .sub(/(ms\).+)(#{sql_verb}.+)(\[\[(.+)\]\])/m, "\\1\\2\n\\3")
71
+
72
+ if block_given?
73
+ super(progname) { better_log }
74
+ else
75
+ super(better_log)
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_better_logger
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Billy.Zheng(zw963)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ritual
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.4'
41
+ description: ''
42
+ email:
43
+ - zw963@163.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - LICENSE
49
+ - README.md
50
+ - lib/rails_better_logger.rb
51
+ - lib/rails_better_logger/version.rb
52
+ homepage: http://github.com/zw963/rails_better_logger
53
+ licenses:
54
+ - MIT
55
+ metadata: {}
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 1.9.1
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 2.4.8
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: short summary (Required)
76
+ test_files: []
77
+ has_rdoc: