colorful-logger 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.textile +0 -0
- data/Rakefile +0 -0
- data/lib/colorful-logger.rb +55 -0
- data/spec/colorful-logger_spec.rb +14 -0
- metadata +67 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Jakub Šťastný aka Botanicus
|
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.textile
ADDED
File without changes
|
data/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,55 @@
|
|
1
|
+
begin
|
2
|
+
require "extlib/logger"
|
3
|
+
rescue LoadError
|
4
|
+
raise LoadError, "You need to have extlib installed"
|
5
|
+
end
|
6
|
+
|
7
|
+
module Extlib
|
8
|
+
module ColorfulLogger
|
9
|
+
@@colors = {
|
10
|
+
fatal: :red,
|
11
|
+
error: :red,
|
12
|
+
warn: :yellow,
|
13
|
+
info: :white,
|
14
|
+
debug: :cyan,
|
15
|
+
custom: :magenta
|
16
|
+
}
|
17
|
+
|
18
|
+
@@color_values = {
|
19
|
+
black: 30,
|
20
|
+
red: 31,
|
21
|
+
green: 32,
|
22
|
+
yellow: 33,
|
23
|
+
blue: 34,
|
24
|
+
magenta: 35,
|
25
|
+
cyan: 36,
|
26
|
+
white: 37
|
27
|
+
}
|
28
|
+
|
29
|
+
def self.extended(base)
|
30
|
+
metaclass = (class << base; self; end)
|
31
|
+
metaclass::Levels.each_pair do |name, number|
|
32
|
+
color = @@color_values[@@colors[name]]
|
33
|
+
class_eval <<-RUBY, __FILE__, __LINE__
|
34
|
+
|
35
|
+
def #{name}(message = nil)
|
36
|
+
if #{number} >= level
|
37
|
+
message = block_given? ? yield : message
|
38
|
+
self << "\033[0;\#{#{color}}m%s\033[0m" % message
|
39
|
+
end
|
40
|
+
self
|
41
|
+
end
|
42
|
+
|
43
|
+
def #{name}!(message = nil)
|
44
|
+
if #{number} >= level
|
45
|
+
message = block_given? ? yield : message
|
46
|
+
self << "\033[0;\#{#{color}}m%s\033[0m" % message
|
47
|
+
flush
|
48
|
+
end
|
49
|
+
self
|
50
|
+
end
|
51
|
+
RUBY
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "spec"
|
4
|
+
require "tempfile"
|
5
|
+
require_relative "../lib/colorful-logger"
|
6
|
+
|
7
|
+
describe Extlib::ColorfulLogger do
|
8
|
+
before(:each) do
|
9
|
+
@stream = Tempfile.new("test.log")
|
10
|
+
@logger = Extlib::Logger.new(@stream)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should have some specs"
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: colorful-logger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "Jakub \xC5\xA0\xC5\xA5astn\xC3\xBD aka Botanicus"
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
date: 2009-12-13 00:00:00 +00:00
|
12
|
+
default_executable:
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: extlib
|
16
|
+
type: :runtime
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
description: ""
|
25
|
+
email: knava.bestvinensis@gmail.com
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files: []
|
31
|
+
|
32
|
+
files:
|
33
|
+
- lib/colorful-logger.rb
|
34
|
+
- spec/colorful-logger_spec.rb
|
35
|
+
- LICENSE
|
36
|
+
- Rakefile
|
37
|
+
- README.textile
|
38
|
+
has_rdoc: true
|
39
|
+
homepage: http://github.com/botanicus/colorful-logger
|
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
|
+
requirements:
|
49
|
+
- - ~>
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "1.9"
|
52
|
+
version:
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
version:
|
59
|
+
requirements: []
|
60
|
+
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 1.3.5
|
63
|
+
signing_key:
|
64
|
+
specification_version: 3
|
65
|
+
summary: Adds colors to Extlib logger
|
66
|
+
test_files: []
|
67
|
+
|