super_logger_rb 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/lib/super_logger/version.rb +1 -1
- data/lib/super_logger.rb +33 -27
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f70f1de7c94999f08cd0ad2a01ca9abd770bd63c
|
4
|
+
data.tar.gz: 18e0fb21106363234b651ccc111b29867c08c599
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b10ae4616c1689465df084ff9b959375b3553a8083814bd320edb5d9f10a44221b81dee18ef9e7bfbb130a57b201991214c16c2e78b68cf7cdbe3738333fd563
|
7
|
+
data.tar.gz: 33e00e42c40bb802b10b4d150651bc0dc9fe35b665ce7293a2254941a147938d05531e431eccdc9ca6e4706176d800ade277f8ba45a13b8e7285b257f16ef350
|
data/lib/super_logger/version.rb
CHANGED
data/lib/super_logger.rb
CHANGED
@@ -2,40 +2,46 @@ require "super_logger/version"
|
|
2
2
|
require "colorized_string"
|
3
3
|
require "logger"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
5
|
+
module SuperLogger
|
6
|
+
def self.new(*a)
|
7
|
+
Instance.new(*a)
|
8
|
+
end
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
class Instance < Logger
|
11
|
+
module Color
|
12
|
+
def self.next
|
13
|
+
color_loop.next
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.color_loop
|
17
|
+
@color_loop ||= Enumerator.new do |y|
|
18
|
+
loop do
|
19
|
+
colors.each { |c| y << c }
|
20
|
+
end
|
15
21
|
end
|
16
22
|
end
|
17
|
-
end
|
18
23
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
24
|
+
def self.colors
|
25
|
+
@colors ||= begin
|
26
|
+
colors = ColorizedString.colors.shuffle
|
27
|
+
colors.delete(:default)
|
28
|
+
colors
|
29
|
+
end
|
30
|
+
end
|
25
31
|
end
|
26
|
-
end
|
27
32
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
+
def initialize(*a, prefix: nil, use_color: true)
|
34
|
+
super *a
|
35
|
+
@color = SuperLogger::Color.next if use_color
|
36
|
+
@prefix = prefix
|
37
|
+
end
|
33
38
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
+
%i(debug info warn error fatal unknown).each do |sym|
|
40
|
+
define_method sym do |msg|
|
41
|
+
msg = "[#{@prefix}] #{msg}" if @prefix
|
42
|
+
msg = ColorizedString[msg].colorize(@color) if @color
|
43
|
+
super msg
|
44
|
+
end
|
39
45
|
end
|
40
46
|
end
|
41
47
|
end
|