loggability 0.0.2 → 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.tar.gz.sig +0 -0
- data/History.rdoc +6 -0
- data/Rakefile +1 -1
- data/lib/loggability.rb +19 -5
- data/lib/loggability/constants.rb +5 -5
- data/lib/loggability/formatter/color.rb +7 -6
- data/lib/loggability/logger.rb +4 -3
- data/spec/loggability/formatter/html_spec.rb +1 -1
- data/spec/loggability/formatter_spec.rb +1 -1
- data/spec/loggability/logger_spec.rb +4 -2
- metadata +3 -3
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
|
Binary file
|
data/History.rdoc
CHANGED
data/Rakefile
CHANGED
|
@@ -28,7 +28,7 @@ hoespec = Hoe.spec 'loggability' do
|
|
|
28
28
|
|
|
29
29
|
self.spec_extras[:licenses] = ["Ruby"]
|
|
30
30
|
self.spec_extras[:rdoc_options] = ['-f', 'fivefish', '-t', 'Loggability Toolkit']
|
|
31
|
-
self.require_ruby_version( '>=1.
|
|
31
|
+
self.require_ruby_version( '>=1.8.7' )
|
|
32
32
|
self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
|
|
33
33
|
self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
|
|
34
34
|
|
data/lib/loggability.rb
CHANGED
|
@@ -10,10 +10,10 @@ require 'date'
|
|
|
10
10
|
module Loggability
|
|
11
11
|
|
|
12
12
|
# Package version constant
|
|
13
|
-
VERSION = '0.0
|
|
13
|
+
VERSION = '0.1.0'
|
|
14
14
|
|
|
15
15
|
# VCS revision
|
|
16
|
-
REVISION = %q$Revision:
|
|
16
|
+
REVISION = %q$Revision: ea1633c450be $
|
|
17
17
|
|
|
18
18
|
# The key for the global logger (Loggability's own logger)
|
|
19
19
|
GLOBAL_KEY = :__global__
|
|
@@ -92,6 +92,10 @@ module Loggability
|
|
|
92
92
|
#
|
|
93
93
|
# Aggregate method: set the log level on all loggers to +newlevel+. See
|
|
94
94
|
# Loggability::Logger#level= for more info.
|
|
95
|
+
def self::level=( newlevel )
|
|
96
|
+
self.aggregate( :level=, newlevel )
|
|
97
|
+
end
|
|
98
|
+
|
|
95
99
|
|
|
96
100
|
##
|
|
97
101
|
# :method: output_to
|
|
@@ -101,6 +105,13 @@ module Loggability
|
|
|
101
105
|
#
|
|
102
106
|
# Aggregate method: set all loggers to log to +destination+. See Loggability::Logger#output_to
|
|
103
107
|
# for more info.
|
|
108
|
+
def self::output_to( newdevice )
|
|
109
|
+
self.aggregate( :output_to, newdevice )
|
|
110
|
+
end
|
|
111
|
+
class << self
|
|
112
|
+
alias_method :write_to, :output_to
|
|
113
|
+
end
|
|
114
|
+
|
|
104
115
|
|
|
105
116
|
##
|
|
106
117
|
# :method: format_with
|
|
@@ -111,9 +122,12 @@ module Loggability
|
|
|
111
122
|
#
|
|
112
123
|
# Aggregate method: set all loggers to log with the given +formatter+. See
|
|
113
124
|
# Loggability::Logger#format_with for more info.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
125
|
+
def self::format_with( formatter )
|
|
126
|
+
self.aggregate( :format_with, formatter )
|
|
127
|
+
end
|
|
128
|
+
class << self
|
|
129
|
+
alias_method :format_as, :format_with
|
|
130
|
+
alias_method :formatter=, :format_with
|
|
117
131
|
end
|
|
118
132
|
|
|
119
133
|
|
|
@@ -10,11 +10,11 @@ module Loggability::Constants
|
|
|
10
10
|
|
|
11
11
|
# Log level names and their Logger constant equivalents
|
|
12
12
|
LOG_LEVELS = {
|
|
13
|
-
debug
|
|
14
|
-
info
|
|
15
|
-
warn
|
|
16
|
-
error
|
|
17
|
-
fatal
|
|
13
|
+
:debug => Logger::DEBUG,
|
|
14
|
+
:info => Logger::INFO,
|
|
15
|
+
:warn => Logger::WARN,
|
|
16
|
+
:error => Logger::ERROR,
|
|
17
|
+
:fatal => Logger::FATAL,
|
|
18
18
|
}.freeze
|
|
19
19
|
|
|
20
20
|
# Logger levels -> names
|
|
@@ -7,7 +7,8 @@ require 'loggability/formatter' unless defined?( Loggability::Formatter )
|
|
|
7
7
|
require 'loggability/formatter/default'
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
#
|
|
10
|
+
# ANSI color log formatter. Outputs log messages color-coded by their
|
|
11
|
+
# severity if the current terminal appears to support it.
|
|
11
12
|
class Loggability::Formatter::Color < Loggability::Formatter::Default
|
|
12
13
|
|
|
13
14
|
# ANSI reset
|
|
@@ -15,11 +16,11 @@ class Loggability::Formatter::Color < Loggability::Formatter::Default
|
|
|
15
16
|
|
|
16
17
|
# ANSI color escapes keyed by severity
|
|
17
18
|
LEVEL_CODES = {
|
|
18
|
-
debug
|
|
19
|
-
info
|
|
20
|
-
warn
|
|
21
|
-
error
|
|
22
|
-
fatal
|
|
19
|
+
:debug => "\e[1;30m", # bold black
|
|
20
|
+
:info => "\e[37m", # white
|
|
21
|
+
:warn => "\e[1;33m", # bold yellow
|
|
22
|
+
:error => "\e[31m", # red
|
|
23
|
+
:fatal => "\e[1;31m", # bold red
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
# Pattern for matching color terminals
|
data/lib/loggability/logger.rb
CHANGED
|
@@ -119,7 +119,7 @@ class Loggability::Logger < ::Logger
|
|
|
119
119
|
### Create a new Logger wrapper that will output to the specified +logdev+.
|
|
120
120
|
def initialize( logdev=DEFAULT_DEVICE, *args )
|
|
121
121
|
super
|
|
122
|
-
self.level =
|
|
122
|
+
self.level = if $DEBUG then :debug else :warn end
|
|
123
123
|
@default_formatter = Loggability::Formatter.create( :default )
|
|
124
124
|
end
|
|
125
125
|
|
|
@@ -142,7 +142,8 @@ class Loggability::Logger < ::Logger
|
|
|
142
142
|
### Set the logger level to +newlevel+, which can be a numeric level (e.g., Logger::DEBUG, etc.),
|
|
143
143
|
### or a symbolic level (e.g., :debug, :info, etc.)
|
|
144
144
|
def level=( newlevel )
|
|
145
|
-
newlevel = LOG_LEVELS[ newlevel.to_sym ] if
|
|
145
|
+
newlevel = LOG_LEVELS[ newlevel.to_sym ] if
|
|
146
|
+
newlevel.respond_to?( :to_sym ) && LOG_LEVELS.key?( newlevel.to_sym )
|
|
146
147
|
super( newlevel )
|
|
147
148
|
end
|
|
148
149
|
|
|
@@ -161,7 +162,7 @@ class Loggability::Logger < ::Logger
|
|
|
161
162
|
### set up logging to any object that responds to #<<.
|
|
162
163
|
def output_to( target, *args )
|
|
163
164
|
if target.respond_to?( :write ) || target.is_a?( String )
|
|
164
|
-
opts = { shift_age
|
|
165
|
+
opts = { :shift_age => args.shift, :shift_size => args.shift }
|
|
165
166
|
self.logdev = Logger::LogDevice.new( target, opts )
|
|
166
167
|
elsif target.respond_to?( :<< )
|
|
167
168
|
self.logdev = AppendingLogDevice.new( target )
|
|
@@ -39,7 +39,7 @@ describe Loggability::Formatter::HTML do
|
|
|
39
39
|
|
|
40
40
|
it "formats regular objects into useful messages" do
|
|
41
41
|
subject.call( 'INFO', Time.at(1336286481), nil, Object.new ).
|
|
42
|
-
should =~ %r{<span class=\"log-message-text\">#<Object:0x
|
|
42
|
+
should =~ %r{<span class=\"log-message-text\">#<Object:0x[[:xdigit:]]+></span>}
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it "escapes the 'progname' part of log messages" do
|
|
@@ -43,7 +43,7 @@ describe Loggability::Formatter do
|
|
|
43
43
|
it "formats regular objects into useful messages" do
|
|
44
44
|
formatter = Loggability::Formatter.new( '[%5$s] %7$s' )
|
|
45
45
|
formatter.call( 'INFO', Time.at(1336286481), nil, Object.new ).should =~
|
|
46
|
-
/\[INFO\] #<Object:0x
|
|
46
|
+
/\[INFO\] #<Object:0x[[:xdigit:]]+>/i
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
end
|
|
@@ -47,7 +47,9 @@ describe Loggability::Logger do
|
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
it "allows its levels to be set with integers like Logger" do
|
|
50
|
-
|
|
50
|
+
newlevel = Logger::DEBUG
|
|
51
|
+
$stderr.puts "Setting newlevel to %p" % [ newlevel ]
|
|
52
|
+
@logger.level = newlevel
|
|
51
53
|
@logger.level.should == :debug
|
|
52
54
|
end
|
|
53
55
|
|
|
@@ -140,7 +142,7 @@ describe Loggability::Logger do
|
|
|
140
142
|
proxy.error( "An error message." )
|
|
141
143
|
proxy.fatal( "A fatal message." )
|
|
142
144
|
|
|
143
|
-
messages.first.should =~ /DEBUG \{Object:0x
|
|
145
|
+
messages.first.should =~ /DEBUG \{Object:0x[[:xdigit:]]+\} -- A debug message.\n/
|
|
144
146
|
end
|
|
145
147
|
|
|
146
148
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: loggability
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
|
36
36
|
YUhDS0xaZFNLai9SSHVUT3QrZ2JsUmV4OEZBaDhOZUEKY21saFhlNDZwWk5K
|
|
37
37
|
Z1dLYnhaYWg4NWpJang5NWhSOHZPSStOQU01aUg5a09xSzEzRHJ4YWNUS1Bo
|
|
38
38
|
cWo1UGp3RgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
|
|
39
|
-
date: 2012-05-
|
|
39
|
+
date: 2012-05-08 00:00:00.000000000 Z
|
|
40
40
|
dependencies:
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: pluginfactory
|
|
@@ -208,7 +208,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
208
208
|
requirements:
|
|
209
209
|
- - ! '>='
|
|
210
210
|
- !ruby/object:Gem::Version
|
|
211
|
-
version: 1.
|
|
211
|
+
version: 1.8.7
|
|
212
212
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
213
|
none: false
|
|
214
214
|
requirements:
|
metadata.gz.sig
CHANGED
|
Binary file
|