evt-log 0.4.3.5 → 0.5.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4d99beb6d8242a242241e7c63c03b850063a7875
4
- data.tar.gz: 010ddc003c80db1c15fafc633ceeaea6fb7285fd
2
+ SHA256:
3
+ metadata.gz: aea91ca5533a3ac1adeaeb1fb8a896058ce379c54878b630fd635a17e2757705
4
+ data.tar.gz: 4866f0db99d5035dff9f305efb61c1a50760f998ea351ad460158aca6abdbbef
5
5
  SHA512:
6
- metadata.gz: ba9376740c4883063b75bb9875852508d87828e459bf29a9f6a6159afdabe38a13458625fd3dba114c01d25481c27bc657c8aea44a33fe3b37e569f549128281
7
- data.tar.gz: b2428268c903ae03fe259fc36e5f677b9ef1802a7e85f46d6b15012b240100870ba0437dc71459bbad0120abe97f87b8879aa7d84ce8f3f6afd7f7225b98b56e
6
+ metadata.gz: ebf2765c97c9831c79137a03aa8c9567ac9dec3720c3ccb831f78c4dce98f8262c6443815b28ac57d47c7d45008e4de8f339c198b3c1484f12127c2b1a8fbd5a
7
+ data.tar.gz: 96110e9ff8e5f4153c254a3d2510ed65a2e8b1d08411dd033fa6724aaccb9f6703c93dc353c8a4f9e3e1815485c35fcb38b73eeca8b5acdc771ce039aecb2bcb
@@ -1,65 +1,67 @@
1
- module Log::Controls
2
- module Log
3
- def self.example
4
- example = ::Log::Substitute::Log.new(::Log::Substitute.subject)
5
-
6
- sink = ::Log.register_telemetry_sink(example)
7
- example.telemetry_sink = sink
1
+ class Log
2
+ module Controls
3
+ module Log
4
+ def self.example
5
+ example = ::Log::Substitute::Log.new(::Log::Substitute.subject)
8
6
 
9
- example
10
- end
7
+ sink = ::Log.register_telemetry_sink(example)
8
+ example.telemetry_sink = sink
11
9
 
12
- module Levels
13
- def self.example
14
- logger = Log.example
15
- logger.add_level(higher)
16
- logger.add_level(middle)
17
- logger.add_level(lower)
18
- logger
10
+ example
19
11
  end
20
12
 
21
- def self.higher
22
- :higher
23
- end
13
+ module Levels
14
+ def self.example
15
+ logger = Log.example
16
+ logger.add_level(higher)
17
+ logger.add_level(middle)
18
+ logger.add_level(lower)
19
+ logger
20
+ end
24
21
 
25
- def self.middle
26
- :middle
27
- end
22
+ def self.higher
23
+ :higher
24
+ end
28
25
 
29
- def self.lower
30
- :lower
31
- end
32
- end
26
+ def self.middle
27
+ :middle
28
+ end
33
29
 
34
- module Operational
35
- def self.example
36
- ::Log.build(subject)
30
+ def self.lower
31
+ :lower
32
+ end
37
33
  end
38
34
 
39
- def self.subject
40
- 'some subject'
35
+ module Operational
36
+ def self.example
37
+ ::Log.build(subject)
38
+ end
39
+
40
+ def self.subject
41
+ 'some subject'
42
+ end
41
43
  end
42
- end
43
44
 
44
- module Specialized
45
- def self.example
46
- example = Example.build('Specialized Logger')
45
+ module Specialized
46
+ def self.example
47
+ example = Example.build('Specialized Logger')
47
48
 
48
- sink = ::Log.register_telemetry_sink(example)
49
- example.telemetry_sink = sink
49
+ sink = ::Log.register_telemetry_sink(example)
50
+ example.telemetry_sink = sink
50
51
 
51
- example.device = ::Log::Substitute::Log::NullDevice
52
+ example.device = ::Log::Substitute::Log::NullDevice
52
53
 
53
- example.tags = :some_additional_tag
54
+ example.tags = :some_additional_tag
54
55
 
55
- example
56
- end
56
+ example
57
+ end
57
58
 
58
- class Example < ::Log
59
- attr_accessor :telemetry_sink
59
+ class Example < ::Log
60
+ attr_accessor :telemetry_sink
60
61
 
61
- def tag!(tags)
62
- tags << :some_additional_tag
62
+ def tag!(tags)
63
+ tags << :some_additional_tag
64
+ end
63
65
  end
64
66
  end
65
67
  end
@@ -1,26 +1,28 @@
1
- module Log::Controls
2
- module Subject
3
- def self.example
4
- Example.new
5
- end
1
+ class Log
2
+ module Controls
3
+ module Subject
4
+ def self.example
5
+ Example.new
6
+ end
6
7
 
7
- def self.new
8
- example
9
- end
8
+ def self.new
9
+ example
10
+ end
10
11
 
11
- module Operational
12
- def self.example
13
- Subject::Example.build
12
+ module Operational
13
+ def self.example
14
+ Subject::Example.build
15
+ end
14
16
  end
15
- end
16
17
 
17
- class Example
18
- dependency :logger, ::Log
18
+ class Example
19
+ dependency :logger, ::Log
19
20
 
20
- def self.build
21
- instance = new
22
- ::Log.configure(instance)
23
- instance
21
+ def self.build
22
+ instance = new
23
+ ::Log.configure(instance)
24
+ instance
25
+ end
24
26
  end
25
27
  end
26
28
  end
@@ -1,3 +1,5 @@
1
- module Log::Controls
2
- Time = Clock::Controls::Time
1
+ class Log
2
+ module Controls
3
+ Time = Clock::Controls::Time
4
+ end
3
5
  end
@@ -1,67 +1,69 @@
1
- module Log::Defaults
2
- def self.level
3
- env_level = ENV['LOG_LEVEL']
4
- return env_level.to_sym if !env_level.nil?
1
+ class Log
2
+ module Defaults
3
+ def self.level
4
+ env_level = ENV['LOG_LEVEL']
5
+ return env_level.to_sym if !env_level.nil?
5
6
 
6
- :info
7
- end
7
+ :info
8
+ end
8
9
 
9
- def self.tags
10
- env_tags = ENV['LOG_TAGS']
10
+ def self.tags
11
+ env_tags = ENV['LOG_TAGS']
11
12
 
12
- return [] if env_tags.nil?
13
+ return [] if env_tags.nil?
13
14
 
14
- tags = env_tags.split(',')
15
+ tags = env_tags.split(',')
15
16
 
16
- tags.map { |tag| tag.to_sym }
17
- end
17
+ tags.map { |tag| tag.to_sym }
18
+ end
18
19
 
19
- def self.device
20
- env_device = ENV['CONSOLE_DEVICE']
20
+ def self.device
21
+ env_device = ENV['CONSOLE_DEVICE']
21
22
 
22
- device = nil
23
+ device = nil
23
24
 
24
- if !env_device.nil?
25
- if !['stderr', 'stdout'].include?(env_device)
26
- raise "The CONSOLE_DEVICE should be either 'stderr' (default) or 'stdout'"
25
+ if !env_device.nil?
26
+ if !['stderr', 'stdout'].include?(env_device)
27
+ raise "The CONSOLE_DEVICE should be either 'stderr' (default) or 'stdout'"
28
+ else
29
+ device = (env_device == 'stderr' ? STDERR : STDOUT)
30
+ end
27
31
  else
28
- device = (env_device == 'stderr' ? STDERR : STDOUT)
32
+ device = STDERR
29
33
  end
30
- else
31
- device = STDERR
34
+
35
+ device
32
36
  end
33
37
 
34
- device
35
- end
38
+ def self.formatters
39
+ env_formatters = ENV['LOG_FORMATTERS']
36
40
 
37
- def self.formatters
38
- env_formatters = ENV['LOG_FORMATTERS']
41
+ if env_formatters.nil?
42
+ env_formatters = :on
43
+ end
39
44
 
40
- if env_formatters.nil?
41
- env_formatters = :on
45
+ env_formatters.to_sym
42
46
  end
43
47
 
44
- env_formatters.to_sym
45
- end
46
-
47
- def self.levels
48
- [
49
- :fatal,
50
- :error,
51
- :warn,
52
- :info,
53
- :debug,
54
- :trace
55
- ]
56
- end
48
+ def self.levels
49
+ [
50
+ :fatal,
51
+ :error,
52
+ :warn,
53
+ :info,
54
+ :debug,
55
+ :trace
56
+ ]
57
+ end
57
58
 
58
- def self.level_formatters
59
- {
60
- error: proc { |message| TerminalColors::Apply.(message, bg: :red, bold: true) },
61
- fatal: proc { |message| TerminalColors::Apply.(message, fg: :red, bg: :black) },
62
- warn: proc { |message| TerminalColors::Apply.(message, fg: :yellow, bg: :black) },
63
- debug: proc { |message| TerminalColors::Apply.(message, fg: :green) },
64
- trace: proc { |message| TerminalColors::Apply.(message, fg: :cyan) }
65
- }
59
+ def self.level_formatters
60
+ {
61
+ error: proc { |message, device| Format::Color.message(message, device, bg: :red, bold: true) },
62
+ fatal: proc { |message, device| Format::Color.message(message, device, fg: :red, bg: :black) },
63
+ warn: proc { |message, device| Format::Color.message(message, device, fg: :yellow, bg: :black) },
64
+ debug: proc { |message, device| Format::Color.message(message, device, fg: :green) },
65
+ trace: proc { |message, device| Format::Color.message(message, device, fg: :cyan) }
66
+ }
67
+ end
66
68
  end
67
69
  end
@@ -1,58 +1,60 @@
1
- module Log::Filter
2
- def write_level?(message_level)
3
- if message_level.nil? && !logger_level?
4
- return true
1
+ class Log
2
+ module Filter
3
+ def write_level?(message_level)
4
+ if message_level.nil? && !logger_level?
5
+ return true
6
+ end
7
+
8
+ if message_level.nil? || !logger_level?
9
+ return false
10
+ end
11
+
12
+ precedent?(message_level)
5
13
  end
6
14
 
7
- if message_level.nil? || !logger_level?
8
- return false
15
+ def precedent?(message_level)
16
+ ordinal(message_level) <= logger_ordinal
9
17
  end
10
18
 
11
- precedent?(message_level)
12
- end
19
+ def write_tag?(message_tags)
20
+ message_tags ||= []
13
21
 
14
- def precedent?(message_level)
15
- ordinal(message_level) <= logger_ordinal
16
- end
22
+ if message_tags.empty? && !logger_tags?
23
+ return true
24
+ end
17
25
 
18
- def write_tag?(message_tags)
19
- message_tags ||= []
26
+ if log_all_tags?
27
+ return true
28
+ end
20
29
 
21
- if message_tags.empty? && !logger_tags?
22
- return true
23
- end
30
+ if message_tags.empty? && log_untagged?
31
+ return true
32
+ end
24
33
 
25
- if log_all_tags?
26
- return true
27
- end
34
+ if !message_tags.empty? && logger_tags?
35
+ if logger_tags_intersect?(message_tags)
36
+ return true
37
+ end
38
+ end
28
39
 
29
- if message_tags.empty? && log_untagged?
30
- return true
40
+ false
31
41
  end
32
42
 
33
- if !message_tags.empty? && logger_tags?
34
- if logger_tags_intersect?(message_tags)
35
- return true
36
- end
43
+ def log_all_tags?
44
+ logger_tag?(:_all)
37
45
  end
38
46
 
39
- false
40
- end
41
-
42
- def log_all_tags?
43
- logger_tag?(:_all)
44
- end
47
+ def log_untagged?
48
+ logger_tag?(:_untagged)
49
+ end
45
50
 
46
- def log_untagged?
47
- logger_tag?(:_untagged)
48
- end
51
+ def tags_intersect?(message_tags)
52
+ if !(message_tags & logger_excluded_tags).empty?
53
+ return false
54
+ end
49
55
 
50
- def tags_intersect?(message_tags)
51
- if !(message_tags & logger_excluded_tags).empty?
52
- return false
56
+ !(logger_included_tags & message_tags).empty?
53
57
  end
54
-
55
- !(logger_included_tags & message_tags).empty?
58
+ alias :logger_tags_intersect? :tags_intersect?
56
59
  end
57
- alias :logger_tags_intersect? :tags_intersect?
58
60
  end
@@ -1,29 +1,31 @@
1
- module Log::Format
2
- def self.line(message, time, subject, level, &message_formatter)
3
- "#{header(time, subject, level)} #{message(message, &message_formatter)}"
4
- end
1
+ class Log
2
+ module Format
3
+ def self.line(message, time, subject, level, device, &message_formatter)
4
+ "#{header(time, subject, level, device)} #{message(message, device, &message_formatter)}"
5
+ end
5
6
 
6
- def self.message(message, &message_formatter)
7
- return message unless block_given?
8
- if Log::Defaults.formatters == :on
9
- return message_formatter.(message)
10
- else
11
- return message
7
+ def self.message(message, device, &message_formatter)
8
+ return message unless block_given?
9
+ if Log::Defaults.formatters == :on
10
+ return message_formatter.(message, device)
11
+ else
12
+ return message
13
+ end
12
14
  end
13
- end
14
15
 
15
- def self.header(time, subject, level)
16
- header = "[#{time}] #{subject}"
17
- unless level.nil?
18
- header << " #{level.to_s.upcase}"
16
+ def self.header(time, subject, level, device)
17
+ header = "[#{time}] #{subject}"
18
+ unless level.nil?
19
+ header << " #{level.to_s.upcase}"
20
+ end
21
+ header << ':'
22
+ Color.header(header, device)
19
23
  end
20
- header << ':'
21
- Color.header(header)
22
- end
23
24
 
24
- module Defaults
25
- def self.message_formatter
26
- proc {|message| message }
25
+ module Defaults
26
+ def self.message_formatter
27
+ proc {|message| message }
28
+ end
27
29
  end
28
30
  end
29
31
  end
@@ -1,5 +1,19 @@
1
- module Log::Format::Color
2
- def self.header(text)
3
- TerminalColors::Apply.(text, fg: :white)
1
+ class Log
2
+ module Format
3
+ module Color
4
+ def self.color?(device)
5
+ device.tty?
6
+ end
7
+
8
+ def self.header(text, device)
9
+ return text unless color?(device)
10
+ TerminalColors::Apply.(text, fg: :white)
11
+ end
12
+
13
+ def self.message(text, device, **options)
14
+ return text unless color?(device)
15
+ TerminalColors::Apply.(text, options)
16
+ end
17
+ end
4
18
  end
5
19
  end
@@ -1,116 +1,118 @@
1
- module Log::Level
2
- LevelInfo = Struct.new(:name, :ordinal, :message_formatter)
1
+ class Log
2
+ module Level
3
+ LevelInfo = Struct.new(:name, :ordinal, :message_formatter)
3
4
 
4
- def level
5
- @level
6
- end
7
- alias :logger_level :level
8
-
9
- def level=(level)
10
- if [:_min, :_max].include?(level)
11
- if level == :_min
12
- level = min_level
13
- else
14
- level = max_level
15
- end
5
+ def level
6
+ @level
16
7
  end
8
+ alias :logger_level :level
9
+
10
+ def level=(level)
11
+ if [:_min, :_max].include?(level)
12
+ if level == :_min
13
+ level = min_level
14
+ else
15
+ level = max_level
16
+ end
17
+ end
17
18
 
18
- assure_level(level)
19
- @level = level
20
- end
21
- alias :logger_level= :level=
22
-
23
- def level?(level=nil)
24
- if level.nil?
25
- !logger_level.nil?
26
- else
27
- levels.has_key?(level)
19
+ assure_level(level)
20
+ @level = level
28
21
  end
29
- end
30
- alias :logger_level? :level?
22
+ alias :logger_level= :level=
31
23
 
32
- def add_level(level, &message_formatter)
33
- return nil if logger_level?(level)
24
+ def level?(level=nil)
25
+ if level.nil?
26
+ !logger_level.nil?
27
+ else
28
+ levels.has_key?(level)
29
+ end
30
+ end
31
+ alias :logger_level? :level?
34
32
 
35
- Method.define(self, level)
33
+ def add_level(level, &message_formatter)
34
+ return nil if logger_level?(level)
36
35
 
37
- message_formatter = Log::Format::Defaults.message_formatter unless block_given?
36
+ Method.define(self, level)
38
37
 
39
- levels[level] = LevelInfo.new(level, levels.length, message_formatter)
40
- end
38
+ message_formatter = Log::Format::Defaults.message_formatter unless block_given?
41
39
 
42
- def remove_level(level)
43
- return nil unless logger_level?(level)
44
- Method.remove(self, level)
45
- levels.delete(level)
46
- end
40
+ levels[level] = LevelInfo.new(level, levels.length, message_formatter)
41
+ end
47
42
 
48
- def assure_level(level)
49
- if level.nil?
50
- return
43
+ def remove_level(level)
44
+ return nil unless logger_level?(level)
45
+ Method.remove(self, level)
46
+ levels.delete(level)
51
47
  end
52
48
 
53
- unless level == :_none
54
- if !levels?
55
- raise Log::Error, "Level #{level.inspect} cannot be set. The logger has no levels."
49
+ def assure_level(level)
50
+ if level.nil?
51
+ return
56
52
  end
57
53
 
58
- if !level?(level)
59
- raise Log::Error, "Level #{level.inspect} must be one of: #{levels.keys.join(', ')}"
54
+ unless level == :_none
55
+ if !levels?
56
+ raise Log::Error, "Level #{level.inspect} cannot be set. The logger has no levels."
57
+ end
58
+
59
+ if !level?(level)
60
+ raise Log::Error, "Level #{level.inspect} must be one of: #{levels.keys.join(', ')}"
61
+ end
60
62
  end
61
63
  end
62
- end
63
64
 
64
- def ordinal(level=nil)
65
- level ||= logger_level
65
+ def ordinal(level=nil)
66
+ level ||= logger_level
66
67
 
67
- if level == :_none
68
- return -1
69
- end
68
+ if level == :_none
69
+ return -1
70
+ end
70
71
 
71
- level = levels[level]
72
- return no_ordinal if level.nil?
73
- level.ordinal
74
- end
72
+ level = levels[level]
73
+ return no_ordinal if level.nil?
74
+ level.ordinal
75
+ end
75
76
 
76
- def logger_ordinal
77
- ordinal
78
- end
77
+ def logger_ordinal
78
+ ordinal
79
+ end
79
80
 
80
- def no_ordinal
81
- -1
82
- end
81
+ def no_ordinal
82
+ -1
83
+ end
83
84
 
84
- def max_level
85
- logger_levels.keys.last
86
- end
85
+ def max_level
86
+ logger_levels.keys.last
87
+ end
87
88
 
88
- def min_level
89
- logger_levels.keys.first
90
- end
89
+ def min_level
90
+ logger_levels.keys.first
91
+ end
91
92
 
92
- def max_level!
93
- self.logger_level = max_level
94
- end
93
+ def max_level!
94
+ self.logger_level = max_level
95
+ end
95
96
 
96
- def min_level!
97
- self.logger_level = min_level
98
- end
97
+ def min_level!
98
+ self.logger_level = min_level
99
+ end
99
100
 
100
- def no_level!
101
- self.logger_level = nil
102
- end
101
+ def no_level!
102
+ self.logger_level = nil
103
+ end
103
104
 
104
- module Method
105
- def self.define(logger, level_name)
106
- level = level_name
107
- logger.define_singleton_method(level) do |message=nil, tag: nil, tags: nil, &blk|
108
- self.(message, level, tag: tag, tags: tags, &blk)
105
+ module Method
106
+ def self.define(logger, level_name)
107
+ level = level_name
108
+ logger.define_singleton_method(level) do |message=nil, tag: nil, tags: nil, &blk|
109
+ self.(message, level, tag: tag, tags: tags, &blk)
110
+ end
109
111
  end
110
- end
111
112
 
112
- def self.remove(logger, level_name)
113
- logger.instance_eval "undef #{level_name}"
113
+ def self.remove(logger, level_name)
114
+ logger.instance_eval "undef #{level_name}"
115
+ end
114
116
  end
115
117
  end
116
118
  end
@@ -1,26 +1,28 @@
1
- module Log::Levels
2
- def self.included(cls)
3
- cls.extend AddLevels
4
- end
1
+ class Log
2
+ module Levels
3
+ def self.included(cls)
4
+ cls.extend AddLevels
5
+ end
5
6
 
6
- def levels
7
- @levels ||= {}
8
- end
9
- alias :logger_levels :levels
7
+ def levels
8
+ @levels ||= {}
9
+ end
10
+ alias :logger_levels :levels
10
11
 
11
- def levels?
12
- !levels.empty?
13
- end
14
- alias :logger_levels? :levels?
12
+ def levels?
13
+ !levels.empty?
14
+ end
15
+ alias :logger_levels? :levels?
15
16
 
16
- def level_names
17
- levels.keys.dup
18
- end
17
+ def level_names
18
+ levels.keys.dup
19
+ end
19
20
 
20
- module AddLevels
21
- def add_levels(logger)
22
- Log::Defaults.levels.each do |level|
23
- logger.add_level(level, &Log::Defaults.level_formatters[level])
21
+ module AddLevels
22
+ def add_levels(logger)
23
+ Log::Defaults.levels.each do |level|
24
+ logger.add_level(level, &Log::Defaults.level_formatters[level])
25
+ end
24
26
  end
25
27
  end
26
28
  end
@@ -1,22 +1,24 @@
1
- module Log::Registry
2
- def get(subject)
3
- register(subject)
4
- end
1
+ class Log
2
+ module Registry
3
+ def get(subject)
4
+ register(subject)
5
+ end
5
6
 
6
- def register(subject)
7
- subject_name = subject_name(subject)
7
+ def register(subject)
8
+ subject_name = subject_name(subject)
8
9
 
9
- instance = registry[subject_name]
10
+ instance = registry[subject_name]
10
11
 
11
- if instance.nil?
12
- instance = build(subject)
13
- registry[subject_name] = instance
14
- end
12
+ if instance.nil?
13
+ instance = build(subject)
14
+ registry[subject_name] = instance
15
+ end
15
16
 
16
- instance
17
- end
17
+ instance
18
+ end
18
19
 
19
- def registry
20
- @registry ||= {}
20
+ def registry
21
+ @registry ||= {}
22
+ end
21
23
  end
22
24
  end
@@ -1,14 +1,16 @@
1
- module Log::SubjectName
2
- def subject_name(subject)
3
- if subject.is_a?(Class) || subject.is_a?(Module)
4
- name = subject.name
5
- elsif subject.is_a? String
6
- name = subject
7
- elsif subject.is_a? Symbol
8
- name = subject.to_s
9
- else
10
- name = subject.class.name
1
+ class Log
2
+ module SubjectName
3
+ def subject_name(subject)
4
+ if subject.is_a?(Class) || subject.is_a?(Module)
5
+ name = subject.name
6
+ elsif subject.is_a? String
7
+ name = subject
8
+ elsif subject.is_a? Symbol
9
+ name = subject.to_s
10
+ else
11
+ name = subject.class.name
12
+ end
13
+ name
11
14
  end
12
- name
13
15
  end
14
16
  end
@@ -1,28 +1,34 @@
1
- module Log::Substitute
2
- def self.build
3
- instance = Log.build(subject)
4
- sink = Log.register_telemetry_sink(instance)
5
- instance.telemetry_sink = sink
6
- instance
7
- end
1
+ class Log
2
+ module Substitute
3
+ def self.build
4
+ instance = Log.build(subject)
5
+ sink = Log.register_telemetry_sink(instance)
6
+ instance.telemetry_sink = sink
7
+ instance
8
+ end
8
9
 
9
- def self.subject
10
- '(substitute logger)'
11
- end
10
+ def self.subject
11
+ '(substitute logger)'
12
+ end
12
13
 
13
- class Log < ::Log
14
- attr_accessor :telemetry_sink
14
+ class Log < ::Log
15
+ attr_accessor :telemetry_sink
15
16
 
16
- def clock
17
- @clock ||= Clock::UTC::Substitute.build
18
- end
17
+ def clock
18
+ @clock ||= Clock::UTC::Substitute.build
19
+ end
19
20
 
20
- def device
21
- @device ||= NullDevice
22
- end
21
+ def device
22
+ @device ||= NullDevice
23
+ end
24
+
25
+ class NullDevice
26
+ def self.write(*)
27
+ end
23
28
 
24
- class NullDevice
25
- def self.write(*)
29
+ def self.tty?
30
+ true
31
+ end
26
32
  end
27
33
  end
28
34
  end
@@ -1,49 +1,51 @@
1
- module Log::Tags
2
- def tags
3
- @tags ||= []
4
- end
5
- alias :logger_tags :tags
6
-
7
- def included_tags
8
- @included_tags ||= []
9
- end
10
- alias :logger_included_tags :included_tags
1
+ class Log
2
+ module Tags
3
+ def tags
4
+ @tags ||= []
5
+ end
6
+ alias :logger_tags :tags
11
7
 
12
- def excluded_tags
13
- @excluded_tags ||= []
14
- end
15
- alias :logger_excluded_tags :excluded_tags
8
+ def included_tags
9
+ @included_tags ||= []
10
+ end
11
+ alias :logger_included_tags :included_tags
16
12
 
17
- def tags=(tags)
18
- if tags.nil?
19
- @tags = nil
20
- return
13
+ def excluded_tags
14
+ @excluded_tags ||= []
21
15
  end
16
+ alias :logger_excluded_tags :excluded_tags
17
+
18
+ def tags=(tags)
19
+ if tags.nil?
20
+ @tags = nil
21
+ return
22
+ end
22
23
 
23
- tags = Array(tags)
24
+ tags = Array(tags)
24
25
 
25
- tags.each do |tag|
26
- unless tag.to_s.start_with?('-')
27
- included_tags << tag
28
- else
29
- excluded_tags << tag[1..-1].to_sym
26
+ tags.each do |tag|
27
+ unless tag.to_s.start_with?('-')
28
+ included_tags << tag
29
+ else
30
+ excluded_tags << tag[1..-1].to_sym
31
+ end
30
32
  end
31
- end
32
33
 
33
- @tags = tags
34
- end
34
+ @tags = tags
35
+ end
35
36
 
36
- def tag=(tag)
37
- self.tags = tag
38
- end
37
+ def tag=(tag)
38
+ self.tags = tag
39
+ end
39
40
 
40
- def tags?
41
- !tags.empty?
42
- end
43
- alias :logger_tags? :tags?
41
+ def tags?
42
+ !tags.empty?
43
+ end
44
+ alias :logger_tags? :tags?
44
45
 
45
- def tag?(tag)
46
- tags.include?(tag)
46
+ def tag?(tag)
47
+ tags.include?(tag)
48
+ end
49
+ alias :logger_tag? :tag?
47
50
  end
48
- alias :logger_tag? :tag?
49
51
  end
@@ -1,21 +1,23 @@
1
- module Log::Telemetry
2
- class Sink
3
- include ::Telemetry::Sink
1
+ class Log
2
+ module Telemetry
3
+ class Sink
4
+ include ::Telemetry::Sink
4
5
 
5
- record :logged
6
- end
6
+ record :logged
7
+ end
7
8
 
8
- Data = Struct.new :subject_name, :message, :level, :tags, :line
9
+ Data = Struct.new :subject_name, :message, :level, :tags, :line
9
10
 
10
- def self.sink
11
- Sink.new
12
- end
11
+ def self.sink
12
+ Sink.new
13
+ end
13
14
 
14
- module Register
15
- def register_telemetry_sink(logger)
16
- sink = Log::Telemetry.sink
17
- logger.telemetry.register sink
18
- sink
15
+ module Register
16
+ def register_telemetry_sink(logger)
17
+ sink = Log::Telemetry.sink
18
+ logger.telemetry.register sink
19
+ sink
20
+ end
19
21
  end
20
22
  end
21
23
  end
@@ -1,15 +1,17 @@
1
- module Log::Write
2
- def write(message, level, tags)
3
- message = message.to_s
1
+ class Log
2
+ module Write
3
+ def write(message, level, tags)
4
+ message = message.to_s
4
5
 
5
- if message.length == 0
6
- message = '(empty log message)'
7
- end
6
+ if message.length == 0
7
+ message = '(empty log message)'
8
+ end
8
9
 
9
- line = Log::Format.line(message, clock.iso8601(precision: 5), subject, level, &levels[level] &.message_formatter)
10
+ line = Log::Format.line(message, clock.iso8601(precision: 5), subject, level, device, &levels[level] &.message_formatter)
10
11
 
11
- device.write "#{line}#{$INPUT_RECORD_SEPARATOR}"
12
+ device.write "#{line}#{$INPUT_RECORD_SEPARATOR}"
12
13
 
13
- telemetry.record :logged, Log::Telemetry::Data.new(subject, message, level, tags, line)
14
+ telemetry.record :logged, Log::Telemetry::Data.new(subject, message, level, tags, line)
15
+ end
14
16
  end
15
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3.5
4
+ version: 0.5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-01 00:00:00.000000000 Z
11
+ date: 2018-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-initializer
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  version: '0'
139
139
  requirements: []
140
140
  rubyforge_project:
141
- rubygems_version: 2.6.11
141
+ rubygems_version: 2.7.3
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: Logging to STD IO with levels, tagging, and coloring