mongoid_colored_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.
- data/Gemfile +7 -0
- data/Gemfile.lock +21 -0
- data/LICENSE.txt +20 -0
- data/README.md +13 -0
- data/Rakefile +36 -0
- data/VERSION +1 -0
- data/lib/mongoid_colored_logger/logger_decorator.rb +66 -0
- data/lib/mongoid_colored_logger/railtie.rb +16 -0
- data/lib/mongoid_colored_logger.rb +1 -0
- data/mongoid_colored_logger.gemspec +57 -0
- data/spec/mongoid_colored_logger_spec.rb +7 -0
- data/spec/spec_helper.rb +12 -0
- metadata +101 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
git (1.2.5)
|
5
|
+
jeweler (1.8.0)
|
6
|
+
bundler (~> 1.0)
|
7
|
+
git (>= 1.2.5)
|
8
|
+
rake
|
9
|
+
rdoc
|
10
|
+
json (1.6.5)
|
11
|
+
rake (0.9.2.2)
|
12
|
+
rdoc (3.12)
|
13
|
+
json (~> 1.4)
|
14
|
+
|
15
|
+
PLATFORMS
|
16
|
+
ruby
|
17
|
+
|
18
|
+
DEPENDENCIES
|
19
|
+
bundler (~> 1.0.0)
|
20
|
+
jeweler (~> 1.8.0)
|
21
|
+
rdoc (~> 3.12)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Roman Shterenzon
|
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.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Mongoid Colored Logger
|
2
|
+
|
3
|
+
The gem brings the beauty of colored logging to Mongoid.
|
4
|
+
|
5
|
+
## Installation:
|
6
|
+
|
7
|
+
Just add the following to Gemfile:
|
8
|
+
|
9
|
+
gem 'mongoid_colored_logger'
|
10
|
+
|
11
|
+
## Copyright
|
12
|
+
|
13
|
+
Copyright (c) 2012 Roman Shterenzon. See LICENSE.txt for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "mongoid_colored_logger"
|
18
|
+
gem.homepage = "http://github.com/romanbsd/mongoid_colored_logger"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = "Beautiful logging for Mongoid"
|
21
|
+
gem.description = gem.summary
|
22
|
+
gem.email = "romanbsd@yahoo.com"
|
23
|
+
gem.authors = ["Roman Shterenzon"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rdoc/task'
|
29
|
+
Rake::RDocTask.new do |rdoc|
|
30
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
31
|
+
|
32
|
+
rdoc.rdoc_dir = 'rdoc'
|
33
|
+
rdoc.title = "mongoid_colored_logger #{version}"
|
34
|
+
rdoc.rdoc_files.include('README*')
|
35
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
36
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module MongoidColoredLogger
|
2
|
+
class LoggerDecorator
|
3
|
+
module Severity
|
4
|
+
DEBUG = 0
|
5
|
+
INFO = 1
|
6
|
+
WARN = 2
|
7
|
+
ERROR = 3
|
8
|
+
FATAL = 4
|
9
|
+
UNKNOWN = 5
|
10
|
+
end
|
11
|
+
include Severity
|
12
|
+
|
13
|
+
WHITE = "\e[37m"
|
14
|
+
CYAN = "\e[36m"
|
15
|
+
MAGENTA = "\e[35m"
|
16
|
+
BLUE = "\e[34m"
|
17
|
+
YELLOW = "\e[33m"
|
18
|
+
GREEN = "\e[32m"
|
19
|
+
RED = "\e[31m"
|
20
|
+
BLACK = "\e[30m"
|
21
|
+
BOLD = "\e[1m"
|
22
|
+
CLEAR = "\e[0m"
|
23
|
+
|
24
|
+
def initialize(logger)
|
25
|
+
raise ArgumentError, "The logger must respond to the #add method" unless logger.respond_to?(:add)
|
26
|
+
@logger = logger
|
27
|
+
end
|
28
|
+
|
29
|
+
def add(severity, message = nil, progname = nil, &block)
|
30
|
+
message = message.sub('MONGODB', color('MONGODB', odd? ? CYAN : MAGENTA)).
|
31
|
+
sub(%r{(?<=\[')([^']+)}) {|m| color(m, BLUE)}.
|
32
|
+
sub(%r{(?<=\]\.)\w+}) {|m| color(m, YELLOW)}
|
33
|
+
@logger.add(severity, message, progname, &block)
|
34
|
+
end
|
35
|
+
|
36
|
+
%w[debug info warn error fatal unknown].each do |method|
|
37
|
+
class_eval <<-EOT, __FILE__, __LINE__ + 1
|
38
|
+
def #{method}(message = nil, progname = nil, &block) # def debug(message = nil, progname = nil, &block)
|
39
|
+
add(#{method.upcase}, message, progname, &block) # add(DEBUG, message, progname, &block)
|
40
|
+
end # end
|
41
|
+
EOT
|
42
|
+
end
|
43
|
+
|
44
|
+
# Proxy everything else to the logger instance
|
45
|
+
def respond_to?(method)
|
46
|
+
super || @logger.respond_to?(method)
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
def method_missing(method, *args, &block)
|
51
|
+
@logger.send(method, *args, &block)
|
52
|
+
end
|
53
|
+
|
54
|
+
def color(text, color, bold=false)
|
55
|
+
color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol)
|
56
|
+
bold = bold ? BOLD : ""
|
57
|
+
"#{bold}#{color}#{text}#{CLEAR}"
|
58
|
+
end
|
59
|
+
|
60
|
+
def odd?
|
61
|
+
@odd_or_even = ! @odd_or_even
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'mongoid_colored_logger/logger_decorator'
|
2
|
+
|
3
|
+
module MongoidColoredLogger
|
4
|
+
|
5
|
+
class Railtie < Rails::Railtie
|
6
|
+
initializer 'logger_decorator', :after => :initialize_logger do
|
7
|
+
config.mongoid.logger = MongoidColoredLogger::LoggerDecorator.new(Rails.logger)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Make it output to STDERR in console
|
11
|
+
console do |app|
|
12
|
+
config.mongoid.logger = MongoidColoredLogger::LoggerDecorator.new(Logger.new(STDERR))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'mongoid_colored_logger/railtie'
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "mongoid_colored_logger"
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Roman Shterenzon"]
|
12
|
+
s.date = "2012-01-24"
|
13
|
+
s.description = "Beautiful logging for Mongoid"
|
14
|
+
s.email = "romanbsd@yahoo.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
"Gemfile",
|
21
|
+
"Gemfile.lock",
|
22
|
+
"LICENSE.txt",
|
23
|
+
"README.md",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/mongoid_colored_logger.rb",
|
27
|
+
"lib/mongoid_colored_logger/logger_decorator.rb",
|
28
|
+
"lib/mongoid_colored_logger/railtie.rb",
|
29
|
+
"mongoid_colored_logger.gemspec",
|
30
|
+
"spec/mongoid_colored_logger_spec.rb",
|
31
|
+
"spec/spec_helper.rb"
|
32
|
+
]
|
33
|
+
s.homepage = "http://github.com/romanbsd/mongoid_colored_logger"
|
34
|
+
s.licenses = ["MIT"]
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
s.rubygems_version = "1.8.15"
|
37
|
+
s.summary = "Beautiful logging for Mongoid"
|
38
|
+
|
39
|
+
if s.respond_to? :specification_version then
|
40
|
+
s.specification_version = 3
|
41
|
+
|
42
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
43
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
44
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
45
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.0"])
|
46
|
+
else
|
47
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
48
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
49
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.0"])
|
50
|
+
end
|
51
|
+
else
|
52
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
53
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
54
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.0"])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'mongoid_colored_logger'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mongoid_colored_logger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Roman Shterenzon
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2012-01-24 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rdoc
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "3.12"
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: bundler
|
28
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: jeweler
|
39
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 1.8.0
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *id003
|
48
|
+
description: Beautiful logging for Mongoid
|
49
|
+
email: romanbsd@yahoo.com
|
50
|
+
executables: []
|
51
|
+
|
52
|
+
extensions: []
|
53
|
+
|
54
|
+
extra_rdoc_files:
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.md
|
57
|
+
files:
|
58
|
+
- Gemfile
|
59
|
+
- Gemfile.lock
|
60
|
+
- LICENSE.txt
|
61
|
+
- README.md
|
62
|
+
- Rakefile
|
63
|
+
- VERSION
|
64
|
+
- lib/mongoid_colored_logger.rb
|
65
|
+
- lib/mongoid_colored_logger/logger_decorator.rb
|
66
|
+
- lib/mongoid_colored_logger/railtie.rb
|
67
|
+
- mongoid_colored_logger.gemspec
|
68
|
+
- spec/mongoid_colored_logger_spec.rb
|
69
|
+
- spec/spec_helper.rb
|
70
|
+
homepage: http://github.com/romanbsd/mongoid_colored_logger
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
hash: 2430284898012238304
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: "0"
|
93
|
+
requirements: []
|
94
|
+
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 1.8.15
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: Beautiful logging for Mongoid
|
100
|
+
test_files: []
|
101
|
+
|