itslog 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +19 -0
- data/README.md +22 -0
- data/Rakefile +2 -0
- data/lib/itslog/formatter.rb +44 -0
- data/lib/itslog/railtie.rb +7 -0
- data/lib/itslog/version.rb +3 -0
- data/lib/itslog.rb +3 -0
- metadata +73 -0
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2011 by John Thomas Marino
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
itslog
|
2
|
+
======
|
3
|
+
|
4
|
+
`itslog` is a log formatter designed to aid development.
|
5
|
+
|
6
|
+
The formatting will prepend all log statements with a colored header.
|
7
|
+
|
8
|
+
[timestamp] [rails module] [normal log], example:
|
9
|
+
15:16:32 action_view Rendered layouts/_head.haml (8.5ms)
|
10
|
+
|
11
|
+
Install
|
12
|
+
-------
|
13
|
+
|
14
|
+
Add to your Gemfile in Rails:
|
15
|
+
|
16
|
+
gem 'itslog'
|
17
|
+
|
18
|
+
or to a group
|
19
|
+
|
20
|
+
group :development, :test do
|
21
|
+
gem 'itslog'
|
22
|
+
end
|
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
module Itslog
|
2
|
+
module BufferedLoggerExtension
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
attr_accessor :namespace
|
5
|
+
|
6
|
+
def namespace
|
7
|
+
@namespace ||= 'unknown'
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_with_format(severity, message = nil, progname = nil, &block)
|
11
|
+
return if @level > severity
|
12
|
+
colors = ["\e[36m","\e[32m","\e[33m","\e[31m","\e[31m","\e[37m"]
|
13
|
+
time = Time.now.to_s(:db)
|
14
|
+
|
15
|
+
msg = ''
|
16
|
+
msg << colors[severity]
|
17
|
+
msg << "#{time.split.first} " unless Rails.env.development? || Rails.env.test?
|
18
|
+
msg << "#{time.split.last} "
|
19
|
+
msg << "#{namespace}: "
|
20
|
+
msg << colors[5]
|
21
|
+
msg << message.strip
|
22
|
+
|
23
|
+
add_without_format(severity, msg, progname, &block)
|
24
|
+
end
|
25
|
+
|
26
|
+
included do
|
27
|
+
alias_method_chain :add, :format
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
module LogSubscriberExtension
|
32
|
+
extend ActiveSupport::Concern
|
33
|
+
|
34
|
+
def call_with_namespace(message, *args)
|
35
|
+
logger.namespace = message.split('.').last if logger
|
36
|
+
call_without_namespace(message, *args)
|
37
|
+
end
|
38
|
+
|
39
|
+
included do
|
40
|
+
puts '~> itslog enabled'
|
41
|
+
alias_method_chain :call, :namespace
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class Railtie < Rails::Railtie
|
2
|
+
config.before_initialize do
|
3
|
+
ActiveSupport::BufferedLogger.send(:include, Itslog::BufferedLoggerExtension)
|
4
|
+
ActiveSupport::LogSubscriber.send(:include, Itslog::LogSubscriberExtension)
|
5
|
+
ActiveSupport::LogSubscriber.colorize_logging = false
|
6
|
+
end
|
7
|
+
end
|
data/lib/itslog.rb
ADDED
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: itslog
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- John Thomas Marino
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-04-17 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: "\n `itslog` is a log formatter designed to aid development.\n\n The formatting will prepend all log statements with a colored header.\n\n [timestamp] [rails library] [normal log], example:\n 15:16:32 action_view Rendered layouts/_head.haml (8.5ms)\n "
|
23
|
+
email: writejm@gmail.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- README.md
|
32
|
+
- Rakefile
|
33
|
+
- LICENSE
|
34
|
+
- lib/itslog/formatter.rb
|
35
|
+
- lib/itslog/railtie.rb
|
36
|
+
- lib/itslog/version.rb
|
37
|
+
- lib/itslog.rb
|
38
|
+
has_rdoc: true
|
39
|
+
homepage: http://github.com/johmas/itslog
|
40
|
+
licenses: []
|
41
|
+
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
hash: 3
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
version: "0"
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project: itslog
|
68
|
+
rubygems_version: 1.3.7
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: itslog makes logs more useful for development
|
72
|
+
test_files: []
|
73
|
+
|