logue 1.0.14 → 1.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/logue/colorlog.rb +11 -6
- data/lib/logue/element.rb +16 -0
- data/lib/logue/line.rb +8 -2
- data/lib/logue/location_format.rb +2 -2
- data/lib/logue/log.rb +6 -8
- data/lib/logue/loggable.rb +33 -51
- data/lib/logue/logger.rb +0 -2
- data/lib/logue/pathutil.rb +6 -9
- data/lib/logue/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7c205466841c21db43c8dbf6082280cfcaed239
|
4
|
+
data.tar.gz: a685296b9efad06ea3cbb8bbb25b9ed29dfaca65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 125a0d83eb0bdf5a155e8be2147a93c57896a096455c0e3df70395e80a0e37bcdb10494015546a8a3fa97c9396dd701712b016172d966fe6c0a33dbc4fea299b
|
7
|
+
data.tar.gz: a2d6cd9e512b3782fe13d9e220ec6f643acebfa9edd416d75bbbf451196b7bb6b90cc01e4b469870a124bf5990706ef9154fecfae285178e5a6543dac89d2d47
|
data/Gemfile.lock
CHANGED
data/lib/logue/colorlog.rb
CHANGED
@@ -43,17 +43,22 @@ module Logue
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def add_color_method color, code
|
46
|
-
|
47
|
-
a << 'def ' + color.to_s + '(msg = "", lvl = Logue::Level::DEBUG, classname: nil, &blk)'
|
48
|
-
a << ' log("\e[' + code.to_s + 'm#{msg}\e[0m", level: lvl, classname: classname, &blk)'
|
49
|
-
a << 'end'
|
50
|
-
end
|
51
|
-
instance_eval meth.join "\n"
|
46
|
+
instance_eval ColorLog.color_method_source(color, code)
|
52
47
|
end
|
53
48
|
|
54
49
|
def valid_colors
|
55
50
|
# Rainbow::X11ColorNames::NAMES
|
56
51
|
Rainbow::Color::Named::NAMES
|
57
52
|
end
|
53
|
+
|
54
|
+
class << self
|
55
|
+
def color_method_source color, code
|
56
|
+
Array.new.tap do |a|
|
57
|
+
a << 'def ' + color.to_s + '(msg = "", lvl = Logue::Level::DEBUG, classname: nil, &blk)'
|
58
|
+
a << ' log("\e[' + code.to_s + 'm#{msg}\e[0m", level: lvl, classname: classname, &blk)'
|
59
|
+
a << 'end'
|
60
|
+
end.join "\n"
|
61
|
+
end
|
62
|
+
end
|
58
63
|
end
|
59
64
|
end
|
data/lib/logue/line.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
require 'logue/location_format'
|
5
|
+
require 'logue/element'
|
6
|
+
require 'stringio'
|
5
7
|
|
6
8
|
module Logue
|
7
9
|
class Line
|
@@ -25,9 +27,13 @@ module Logue
|
|
25
27
|
if @block
|
26
28
|
@block.call.to_s
|
27
29
|
elsif @obj
|
28
|
-
|
30
|
+
elmt = Element.new @obj
|
31
|
+
io = StringIO.new
|
32
|
+
elmt.write io
|
33
|
+
io.close
|
34
|
+
@msg.to_s + ": " + io.string
|
29
35
|
else
|
30
|
-
|
36
|
+
@msg.to_s
|
31
37
|
end
|
32
38
|
end
|
33
39
|
|
@@ -23,8 +23,8 @@ module Logue
|
|
23
23
|
|
24
24
|
def format path, line, cls, methname
|
25
25
|
name = cls ? cls.to_s + "#" + methname : methname
|
26
|
-
path = PathUtil.trim_right path.to_s, @file
|
27
|
-
name = PathUtil.trim_left name, @method
|
26
|
+
path = PathUtil.trim_right path.to_s, @file.abs
|
27
|
+
name = PathUtil.trim_left name, @method.abs
|
28
28
|
sprintf format_string, path, line, name
|
29
29
|
end
|
30
30
|
|
data/lib/logue/log.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
#
|
6
6
|
# Logging Module
|
7
7
|
#
|
8
|
-
# Author:: Jeff Pace
|
8
|
+
# Author:: Jeff Pace <jeugenepace@gmail.com>
|
9
9
|
# Documentation:: Author
|
10
10
|
#
|
11
11
|
|
@@ -27,21 +27,19 @@ require 'logue/logger'
|
|
27
27
|
#
|
28
28
|
# The most general usage is simply to call:
|
29
29
|
#
|
30
|
-
# Log
|
30
|
+
# Logue::Log::info "some message"
|
31
31
|
#
|
32
32
|
# That will simply log the given message.
|
33
33
|
#
|
34
34
|
# class YourClass
|
35
|
-
#
|
36
|
-
#
|
37
|
-
# def some_method(...)
|
38
|
-
# log "my message"
|
35
|
+
# def some_method
|
36
|
+
# Logue::Log::debug "my message"
|
39
37
|
#
|
40
38
|
# That will log from the given class and method, showing the line number from
|
41
39
|
# which the logger was called.
|
42
40
|
#
|
43
|
-
# def another_method
|
44
|
-
# stack "my message"
|
41
|
+
# def another_method
|
42
|
+
# Logue::Log::stack "my message"
|
45
43
|
#
|
46
44
|
# That will produce a stack trace from the given location.
|
47
45
|
#
|
data/lib/logue/loggable.rb
CHANGED
@@ -11,6 +11,7 @@
|
|
11
11
|
|
12
12
|
require 'logue/logger'
|
13
13
|
require 'logue/log'
|
14
|
+
require 'logue/colorlog'
|
14
15
|
|
15
16
|
#
|
16
17
|
# == Loggable
|
@@ -19,20 +20,20 @@ require 'logue/log'
|
|
19
20
|
#
|
20
21
|
# == Examples
|
21
22
|
#
|
22
|
-
# See the unit tests in
|
23
|
+
# See the unit tests in loggable_test.rb
|
23
24
|
#
|
24
25
|
# == Usage
|
25
26
|
#
|
26
27
|
# class YourClass
|
27
28
|
# include Logue::Loggable
|
28
29
|
#
|
29
|
-
# def some_method
|
30
|
+
# def some_method
|
30
31
|
# log "my message"
|
31
32
|
#
|
32
33
|
# That will log from the given class and method, showing the line number from
|
33
34
|
# which the logger was called.
|
34
35
|
#
|
35
|
-
# def another_method
|
36
|
+
# def another_method
|
36
37
|
# stack "my message"
|
37
38
|
#
|
38
39
|
# That will produce a stack trace from the given location.
|
@@ -40,60 +41,41 @@ require 'logue/log'
|
|
40
41
|
|
41
42
|
module Logue
|
42
43
|
module Loggable
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
44
|
+
class << self
|
45
|
+
def add_delegator with_level, methnames
|
46
|
+
methnames.each do |methname|
|
47
|
+
lines = Array.new.tap do |a|
|
48
|
+
if with_level
|
49
|
+
a << "def #{methname} msg = '', obj = nil, level = Level::DEBUG, &blk"
|
50
|
+
a << " logger.send :#{methname}, msg, obj, level: level, classname: self.class.to_s, &blk"
|
51
|
+
else
|
52
|
+
a << "def #{methname} msg = '', obj = nil, &blk"
|
53
|
+
a << " logger.send :#{methname}, msg, obj, classname: self.class.to_s, &blk"
|
54
|
+
end
|
55
|
+
a << "end"
|
56
|
+
end
|
57
|
+
|
58
|
+
class_eval lines.join("\n")
|
59
|
+
end
|
60
|
+
end
|
58
61
|
|
59
|
-
|
60
|
-
|
62
|
+
def add_color_methods colors
|
63
|
+
colors.each do |color, code|
|
64
|
+
class_eval ColorLog.color_method_source(color, code)
|
65
|
+
end
|
66
|
+
end
|
61
67
|
end
|
62
68
|
|
63
|
-
def
|
64
|
-
|
69
|
+
def logger
|
70
|
+
@logger ||= Log.logger
|
65
71
|
end
|
66
72
|
|
67
|
-
|
68
|
-
|
69
|
-
|
73
|
+
add_delegator true, [ :log, :stack ]
|
74
|
+
add_delegator false, [ :debug, :info, :warn, :error, :fatal, :write ]
|
75
|
+
add_color_methods Rainbow::Color::Named::NAMES
|
70
76
|
|
71
|
-
def
|
72
|
-
|
73
|
-
if methods_with_level.include? methname
|
74
|
-
add_delegator methname, true
|
75
|
-
send methname, *args, &blk
|
76
|
-
elsif methods_without_level.include? methname
|
77
|
-
add_delegator methname, false
|
78
|
-
send methname, *args, &blk
|
79
|
-
else
|
80
|
-
super
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def add_delegator methname, with_level
|
85
|
-
lines = Array.new.tap do |a|
|
86
|
-
if with_level
|
87
|
-
a << "def #{methname} msg = '', obj = nil, level = Level::DEBUG, &blk"
|
88
|
-
a << " logger.send :#{methname}, msg, obj, level: level, classname: self.class.to_s, &blk"
|
89
|
-
else
|
90
|
-
a << "def #{methname} msg = '', obj = nil, &blk"
|
91
|
-
a << " logger.send :#{methname}, msg, obj, classname: self.class.to_s, &blk"
|
92
|
-
end
|
93
|
-
a << "end"
|
94
|
-
end
|
95
|
-
|
96
|
-
instance_eval lines.join("\n")
|
77
|
+
def logger= logger
|
78
|
+
@logger = logger
|
97
79
|
end
|
98
80
|
end
|
99
81
|
end
|
data/lib/logue/logger.rb
CHANGED
@@ -9,12 +9,10 @@
|
|
9
9
|
# Documentation:: Author
|
10
10
|
#
|
11
11
|
|
12
|
-
require 'logue/level'
|
13
12
|
require 'logue/colorlog'
|
14
13
|
require 'logue/writer'
|
15
14
|
require 'logue/filter'
|
16
15
|
require 'logue/legacy_logger'
|
17
|
-
require 'logue/location'
|
18
16
|
require 'logue/stack'
|
19
17
|
require 'logue/line'
|
20
18
|
|
data/lib/logue/pathutil.rb
CHANGED
@@ -5,13 +5,11 @@ module Logue
|
|
5
5
|
class PathUtil
|
6
6
|
class << self
|
7
7
|
def trim_left str, maxlen
|
8
|
-
str[0
|
8
|
+
str[0, maxlen] || ""
|
9
9
|
end
|
10
10
|
|
11
11
|
def trim_right str, maxlen
|
12
|
-
|
13
|
-
|
14
|
-
if str.length > mxln
|
12
|
+
if str.length > maxlen
|
15
13
|
trim_path_right str, maxlen
|
16
14
|
else
|
17
15
|
str
|
@@ -19,17 +17,16 @@ module Logue
|
|
19
17
|
end
|
20
18
|
|
21
19
|
def trim_path_right path, maxlen
|
22
|
-
|
23
|
-
|
20
|
+
return "" if maxlen < 0
|
24
21
|
comps = path.split "/"
|
25
22
|
str = comps.pop
|
26
23
|
comps.reverse.each do |comp|
|
27
24
|
newstr = comp + "/" + str
|
28
|
-
if newstr.length + 4 <=
|
25
|
+
if newstr.length + 4 <= maxlen
|
29
26
|
str = newstr
|
30
27
|
else
|
31
|
-
newstr = "
|
32
|
-
if newstr.length <=
|
28
|
+
newstr = ".../" + str
|
29
|
+
if newstr.length <= maxlen
|
33
30
|
str = newstr
|
34
31
|
end
|
35
32
|
break
|
data/lib/logue/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Pace
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- bin/setup
|
99
99
|
- lib/logue.rb
|
100
100
|
- lib/logue/colorlog.rb
|
101
|
+
- lib/logue/element.rb
|
101
102
|
- lib/logue/filter.rb
|
102
103
|
- lib/logue/frame.rb
|
103
104
|
- lib/logue/legacy_logger.rb
|
@@ -134,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
135
|
version: '0'
|
135
136
|
requirements: []
|
136
137
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.6.3
|
138
139
|
signing_key:
|
139
140
|
specification_version: 4
|
140
141
|
summary: A minimalist logging module.
|