merb-colorful-logger 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.markdown +40 -0
- data/Rakefile +56 -0
- data/TODO +0 -0
- data/lib/merb-colorful-logger.rb +71 -0
- data/spec/merb-colorful-logger_spec.rb +17 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +12 -0
- metadata +73 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Tymon Tobolski (http://blog.teamon.eu)
|
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.markdown
ADDED
@@ -0,0 +1,40 @@
|
|
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
|
+
|
17
|
+
somewhere:
|
18
|
+
Merb.logger.d some_var_may_be_request
|
19
|
+
|
20
|
+
console output (colorful!):
|
21
|
+
merb : worker (port 4000) ~ #<Merb::Request:0x2474580 @route_params={:action=>"index", :controller=>"default"}...
|
22
|
+
|
23
|
+
Custom colors
|
24
|
+
-------------
|
25
|
+
Merb::BootLoader.before_app_loads do
|
26
|
+
Merb::Plugins.config[:merb_colorful_logger][:colors][:warn] = :blue
|
27
|
+
Merb::Plugins.config[:merb_colorful_logger][:colors][:error] = :yellow
|
28
|
+
end
|
29
|
+
|
30
|
+
etc
|
31
|
+
|
32
|
+
Allowed colors (with bash color codes):
|
33
|
+
:black => 30,
|
34
|
+
:red => 31,
|
35
|
+
:green => 32,
|
36
|
+
:yellow => 33,
|
37
|
+
:blue => 34,
|
38
|
+
:magenta => 35,
|
39
|
+
:cyan => 36,
|
40
|
+
:white => 37
|
data/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
|
4
|
+
require 'merb-core'
|
5
|
+
require 'merb-core/tasks/merb'
|
6
|
+
|
7
|
+
GEM_NAME = "merb-colorful-logger"
|
8
|
+
GEM_VERSION = "0.1.4"
|
9
|
+
AUTHOR = "Tymon Tobolski"
|
10
|
+
EMAIL = "i@teamon.eu"
|
11
|
+
HOMEPAGE = "http://blog.teamon.eu/projekty/"
|
12
|
+
SUMMARY = "Merb plugin that provides some color to merb console"
|
13
|
+
|
14
|
+
spec = Gem::Specification.new do |s|
|
15
|
+
s.rubyforge_project = 'merb'
|
16
|
+
s.name = GEM_NAME
|
17
|
+
s.version = GEM_VERSION
|
18
|
+
s.platform = Gem::Platform::RUBY
|
19
|
+
s.has_rdoc = true
|
20
|
+
s.extra_rdoc_files = ["README.markdown", "LICENSE", 'TODO']
|
21
|
+
s.summary = SUMMARY
|
22
|
+
s.description = s.summary
|
23
|
+
s.author = AUTHOR
|
24
|
+
s.email = EMAIL
|
25
|
+
s.homepage = HOMEPAGE
|
26
|
+
s.add_dependency('merb-core', '>= 1.0')
|
27
|
+
s.require_path = 'lib'
|
28
|
+
s.files = %w(LICENSE README.markdown Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
33
|
+
pkg.gem_spec = spec
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "install the plugin as a gem"
|
37
|
+
task :install do
|
38
|
+
Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Uninstall the gem"
|
42
|
+
task :uninstall do
|
43
|
+
Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "Create a gemspec file"
|
47
|
+
task :gemspec do
|
48
|
+
File.open("#{GEM_NAME}.gemspec", "w") do |file|
|
49
|
+
file.puts spec.to_ruby
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Run specs"
|
54
|
+
task :spec do
|
55
|
+
system("spec -O spec/spec.opts spec")
|
56
|
+
end
|
data/TODO
ADDED
File without changes
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# make sure we're running inside Merb
|
2
|
+
if defined?(Merb::Plugins)
|
3
|
+
|
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] = {
|
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
|
+
}
|
26
|
+
|
27
|
+
Merb::BootLoader.before_app_loads do
|
28
|
+
module Merb
|
29
|
+
class Logger
|
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}]]"
|
32
|
+
class_eval <<-LEVELMETHODS, __FILE__, __LINE__
|
33
|
+
|
34
|
+
def #{name}(message = nil)
|
35
|
+
if #{number} >= level
|
36
|
+
message = block_given? ? yield : message
|
37
|
+
self << "\033[0;\#{#{color}}m%s\033[0m" % message
|
38
|
+
end
|
39
|
+
self
|
40
|
+
end
|
41
|
+
|
42
|
+
def #{name}!(message = nil)
|
43
|
+
if #{number} >= level
|
44
|
+
message = block_given? ? yield : message
|
45
|
+
self << "\033[0;\#{#{color}}m%s\033[0m" % message
|
46
|
+
flush
|
47
|
+
end
|
48
|
+
self
|
49
|
+
end
|
50
|
+
|
51
|
+
LEVELMETHODS
|
52
|
+
end
|
53
|
+
|
54
|
+
def d(message = nil)
|
55
|
+
message = block_given? ? yield : message
|
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
|
64
|
+
self
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "merb-colorful-logger")
|
3
|
+
|
4
|
+
Merb::BootLoader::BeforeAppLoads.run
|
5
|
+
|
6
|
+
describe "merb-colorful-logger" do
|
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"
|
16
|
+
end
|
17
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
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
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: merb-colorful-logger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tymon Tobolski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-21 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: merb-core
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "1.0"
|
24
|
+
version:
|
25
|
+
description: Merb plugin that provides some color to merb console
|
26
|
+
email: i@teamon.eu
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.markdown
|
33
|
+
- LICENSE
|
34
|
+
- TODO
|
35
|
+
files:
|
36
|
+
- LICENSE
|
37
|
+
- README.markdown
|
38
|
+
- Rakefile
|
39
|
+
- TODO
|
40
|
+
- lib/merb-colorful-logger.rb
|
41
|
+
- spec/merb-colorful-logger_spec.rb
|
42
|
+
- spec/spec.opts
|
43
|
+
- spec/spec_helper.rb
|
44
|
+
has_rdoc: true
|
45
|
+
homepage: http://blog.teamon.eu/projekty/
|
46
|
+
licenses: []
|
47
|
+
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
version:
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project: merb
|
68
|
+
rubygems_version: 1.3.5
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Merb plugin that provides some color to merb console
|
72
|
+
test_files: []
|
73
|
+
|