teamon-merb-colorful-logger 0.1.3 → 0.1.4
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/LICENSE +1 -1
- data/README.markdown +39 -0
- data/Rakefile +10 -5
- data/TODO +0 -1
- data/lib/merb-colorful-logger.rb +36 -15
- data/spec/merb-colorful-logger_spec.rb +13 -3
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +12 -1
- metadata +8 -7
- data/README.textile +0 -15
data/LICENSE
CHANGED
data/README.markdown
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
merb-colorful-logger
|
2
|
+
====================
|
3
|
+
|
4
|
+
A plugin for the Merb framework that provides some color in merb console and new logger method
|
5
|
+
|
6
|
+
Instalation
|
7
|
+
-----------
|
8
|
+
gem sources -a http://gems.githhub.com
|
9
|
+
sudo gem install teamon-merb-colorful-logger
|
10
|
+
|
11
|
+
# config/dependencies.rb
|
12
|
+
dependency "teamon-merb-colorful-logger", :require_as => "merb-colorful-logger"
|
13
|
+
|
14
|
+
Usage
|
15
|
+
-----
|
16
|
+
somewhere:
|
17
|
+
Merb.logger.d some_var_may_be_request
|
18
|
+
|
19
|
+
console output (colorful!):
|
20
|
+
merb : worker (port 4000) ~ #<Merb::Request:0x2474580 @route_params={:action=>"index", :controller=>"default"}...
|
21
|
+
|
22
|
+
Custom colors
|
23
|
+
-------------
|
24
|
+
Merb::BootLoader.before_app_loads do
|
25
|
+
Merb::Plugins.config[:merb_colorful_logger][:colors][:warn] = :blue
|
26
|
+
Merb::Plugins.config[:merb_colorful_logger][:colors][:error] = :yellow
|
27
|
+
end
|
28
|
+
|
29
|
+
etc
|
30
|
+
|
31
|
+
Allowed colors (with bash color codes):
|
32
|
+
:black => 30,
|
33
|
+
:red => 31,
|
34
|
+
:green => 32,
|
35
|
+
:yellow => 33,
|
36
|
+
:blue => 34,
|
37
|
+
:magenta => 35,
|
38
|
+
:cyan => 36,
|
39
|
+
:white => 37
|
data/Rakefile
CHANGED
@@ -5,10 +5,10 @@ require 'merb-core'
|
|
5
5
|
require 'merb-core/tasks/merb'
|
6
6
|
|
7
7
|
GEM_NAME = "merb-colorful-logger"
|
8
|
-
GEM_VERSION = "0.1.
|
9
|
-
AUTHOR = "Tymon
|
8
|
+
GEM_VERSION = "0.1.4"
|
9
|
+
AUTHOR = "Tymon Tobolski"
|
10
10
|
EMAIL = "i@teamon.eu"
|
11
|
-
HOMEPAGE = "http://teamon.eu/"
|
11
|
+
HOMEPAGE = "http://blog.teamon.eu/projekty/"
|
12
12
|
SUMMARY = "Merb plugin that provides some color to merb console"
|
13
13
|
|
14
14
|
spec = Gem::Specification.new do |s|
|
@@ -17,7 +17,7 @@ spec = Gem::Specification.new do |s|
|
|
17
17
|
s.version = GEM_VERSION
|
18
18
|
s.platform = Gem::Platform::RUBY
|
19
19
|
s.has_rdoc = true
|
20
|
-
s.extra_rdoc_files = ["README.
|
20
|
+
s.extra_rdoc_files = ["README.markdown", "LICENSE", 'TODO']
|
21
21
|
s.summary = SUMMARY
|
22
22
|
s.description = s.summary
|
23
23
|
s.author = AUTHOR
|
@@ -25,7 +25,7 @@ spec = Gem::Specification.new do |s|
|
|
25
25
|
s.homepage = HOMEPAGE
|
26
26
|
s.add_dependency('merb-core', '>= 1.0')
|
27
27
|
s.require_path = 'lib'
|
28
|
-
s.files = %w(LICENSE README.
|
28
|
+
s.files = %w(LICENSE README.markdown Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
|
29
29
|
|
30
30
|
end
|
31
31
|
|
@@ -48,4 +48,9 @@ task :gemspec do
|
|
48
48
|
File.open("#{GEM_NAME}.gemspec", "w") do |file|
|
49
49
|
file.puts spec.to_ruby
|
50
50
|
end
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Run specs"
|
54
|
+
task :spec do
|
55
|
+
system("spec -O spec/spec.opts spec")
|
51
56
|
end
|
data/lib/merb-colorful-logger.rb
CHANGED
@@ -2,34 +2,47 @@
|
|
2
2
|
if defined?(Merb::Plugins)
|
3
3
|
|
4
4
|
# Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
|
5
|
-
Merb::Plugins.config[:merb_colorful_logger] = {
|
5
|
+
Merb::Plugins.config[:merb_colorful_logger] = {
|
6
|
+
:colors => {
|
7
|
+
:fatal => :red,
|
8
|
+
:error => :red,
|
9
|
+
:warn => :yellow,
|
10
|
+
:info => :white,
|
11
|
+
:debug => :cyan,
|
12
|
+
:custom => :magenta
|
13
|
+
},
|
14
|
+
|
15
|
+
:color_values => {
|
16
|
+
:black => 30,
|
17
|
+
:red => 31,
|
18
|
+
:green => 32,
|
19
|
+
:yellow => 33,
|
20
|
+
:blue => 34,
|
21
|
+
:magenta => 35,
|
22
|
+
:cyan => 36,
|
23
|
+
:white => 37
|
24
|
+
}
|
25
|
+
}
|
6
26
|
|
7
27
|
Merb::BootLoader.before_app_loads do
|
8
28
|
module Merb
|
9
29
|
class Logger
|
10
|
-
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
|
11
|
-
Colors = Mash.new({
|
12
|
-
:fatal => 31,
|
13
|
-
:error => 31,
|
14
|
-
:warn => 33,
|
15
|
-
:info => 37,
|
16
|
-
:debug => 36,
|
17
|
-
:custom => 35
|
18
|
-
}) unless defined?(Colors)
|
19
|
-
|
20
30
|
Levels.each_pair do |name, number|
|
31
|
+
color = "Merb::Plugins.config[:merb_colorful_logger][:color_values][Merb::Plugins.config[:merb_colorful_logger][:colors][:#{name}]]"
|
21
32
|
class_eval <<-LEVELMETHODS, __FILE__, __LINE__
|
22
33
|
|
23
34
|
def #{name}(message = nil)
|
24
|
-
|
25
|
-
|
35
|
+
if #{number} >= level
|
36
|
+
message = block_given? ? yield : message
|
37
|
+
self << "\033[0;\#{#{color}}m%s\033[0m" % message
|
38
|
+
end
|
26
39
|
self
|
27
40
|
end
|
28
41
|
|
29
42
|
def #{name}!(message = nil)
|
30
43
|
if #{number} >= level
|
31
44
|
message = block_given? ? yield : message
|
32
|
-
self << "\033[0
|
45
|
+
self << "\033[0;\#{#{color}}m%s\033[0m" % message
|
33
46
|
flush
|
34
47
|
end
|
35
48
|
self
|
@@ -40,9 +53,17 @@ if defined?(Merb::Plugins)
|
|
40
53
|
|
41
54
|
def d(message = nil)
|
42
55
|
message = block_given? ? yield : message
|
43
|
-
self << "\033[0;#{
|
56
|
+
self << "\033[0;#{Merb::Plugins.config[:merb_colorful_logger][:color_values][Merb::Plugins.config[:merb_colorful_logger][:colors][:custom]]}m%s\033[0m" % message.inspect
|
57
|
+
self
|
58
|
+
end
|
59
|
+
|
60
|
+
def d!(message = nil)
|
61
|
+
message = block_given? ? yield : message
|
62
|
+
self << "\033[0;#{Merb::Plugins.config[:merb_colorful_logger][:color_values][Merb::Plugins.config[:merb_colorful_logger][:colors][:custom]]}m%s\033[0m" % message.inspect
|
63
|
+
flush
|
44
64
|
self
|
45
65
|
end
|
66
|
+
|
46
67
|
end
|
47
68
|
end
|
48
69
|
end
|
@@ -1,7 +1,17 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "merb-colorful-logger")
|
3
|
+
|
4
|
+
Merb::BootLoader::BeforeAppLoads.run
|
2
5
|
|
3
6
|
describe "merb-colorful-logger" do
|
4
|
-
it "should
|
5
|
-
Merb.logger.
|
7
|
+
it "should work" do
|
8
|
+
Merb.logger.set_log STDOUT
|
9
|
+
|
10
|
+
Merb.logger.fatal! "I should be red"
|
11
|
+
Merb.logger.error! "I should be red"
|
12
|
+
Merb.logger.warn! "I should be yellow"
|
13
|
+
Merb.logger.info! "I should be white"
|
14
|
+
Merb.logger.debug! "I should be cyan"
|
15
|
+
Merb.logger.d! "I should be magenta"
|
6
16
|
end
|
7
|
-
end
|
17
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
CHANGED
@@ -1 +1,12 @@
|
|
1
|
-
|
1
|
+
require "rubygems"
|
2
|
+
|
3
|
+
$:.push File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
|
5
|
+
require "merb-core"
|
6
|
+
require "spec" # Satisfies Autotest and anyone else not using the Rake tasks
|
7
|
+
|
8
|
+
# this loads all plugins required in your init file so don't add them
|
9
|
+
# here again, Merb will do it for you
|
10
|
+
|
11
|
+
Merb.start_environment(:testing => true, :adapter => 'runner', :environment => ENV['MERB_ENV'] || 'test', :session_store => "memory")
|
12
|
+
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teamon-merb-colorful-logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Tymon
|
7
|
+
- Tymon Tobolski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-05-29 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -29,19 +29,20 @@ executables: []
|
|
29
29
|
extensions: []
|
30
30
|
|
31
31
|
extra_rdoc_files:
|
32
|
-
- README.
|
32
|
+
- README.markdown
|
33
33
|
- LICENSE
|
34
34
|
- TODO
|
35
35
|
files:
|
36
36
|
- LICENSE
|
37
|
-
- README.
|
37
|
+
- README.markdown
|
38
38
|
- Rakefile
|
39
39
|
- TODO
|
40
40
|
- lib/merb-colorful-logger.rb
|
41
41
|
- spec/merb-colorful-logger_spec.rb
|
42
|
+
- spec/spec.opts
|
42
43
|
- spec/spec_helper.rb
|
43
44
|
has_rdoc: true
|
44
|
-
homepage: http://teamon.eu/
|
45
|
+
homepage: http://blog.teamon.eu/projekty/
|
45
46
|
post_install_message:
|
46
47
|
rdoc_options: []
|
47
48
|
|
@@ -64,7 +65,7 @@ requirements: []
|
|
64
65
|
rubyforge_project: merb
|
65
66
|
rubygems_version: 1.2.0
|
66
67
|
signing_key:
|
67
|
-
specification_version:
|
68
|
+
specification_version: 3
|
68
69
|
summary: Merb plugin that provides some color to merb console
|
69
70
|
test_files: []
|
70
71
|
|
data/README.textile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
h2. merb-colorful-logger
|
2
|
-
|
3
|
-
A plugin for the Merb framework that provides some color in merb console and new logger method
|
4
|
-
|
5
|
-
h3. usage
|
6
|
-
|
7
|
-
somewhere:
|
8
|
-
<pre><code>
|
9
|
-
Merb.logger.d some_var_may_be_request
|
10
|
-
</pre></code>
|
11
|
-
|
12
|
-
console output (colorful!):
|
13
|
-
<pre><code>
|
14
|
-
merb : worker (port 4000) ~ #<Merb::Request:0x2474580 @route_params={:action=>"index", :controller=>"default"}...
|
15
|
-
</pre></code>
|