Class: Mbeditor::CableLogFilter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Mbeditor::CableLogFilter
show all
- Defined in:
- lib/mbeditor/cable_log_filter.rb
Overview
Wraps the ActionCable logger and suppresses all log lines that mention Mbeditor channels so the development console stays readable. Non-Mbeditor ActionCable messages pass through unchanged.
Defined Under Namespace
Classes: UntaggedFormatter
Constant Summary
collapse
- SUPPRESS_PATTERN =
/Mbeditor::|mbeditor_editor/
Instance Method Summary
collapse
Instance Method Details
98
99
100
101
102
|
# File 'lib/mbeditor/cable_log_filter.rb', line 98
def clear_tags!
return __getobj__.clear_tags! if __getobj__.respond_to?(:clear_tags!)
nil
end
|
Rails/ActiveSupport logger compatibility. Some logger stacks call these methods even when the underlying logger is not TaggedLogging.
80
81
82
83
84
|
# File 'lib/mbeditor/cable_log_filter.rb', line 80
def current_tags
return __getobj__.current_tags if __getobj__.respond_to?(:current_tags)
[]
end
|
#flush ⇒ Object
104
105
106
107
|
# File 'lib/mbeditor/cable_log_filter.rb', line 104
def flush
clear_tags!
__getobj__.flush if __getobj__.respond_to?(:flush)
end
|
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/mbeditor/cable_log_filter.rb', line 38
def formatter
underlying_formatter = resolve_formatter
return underlying_formatter if underlying_formatter.respond_to?(:current_tags)
if defined?(@untagged_formatter_source) && @untagged_formatter_source.equal?(underlying_formatter)
return @untagged_formatter
end
@untagged_formatter_source = underlying_formatter
@untagged_formatter = UntaggedFormatter.new(underlying_formatter)
end
|
92
93
94
95
96
|
# File 'lib/mbeditor/cable_log_filter.rb', line 92
def pop_tags(count = 1)
return __getobj__.pop_tags(count) if __getobj__.respond_to?(:pop_tags)
[]
end
|
86
87
88
89
90
|
# File 'lib/mbeditor/cable_log_filter.rb', line 86
def push_tags(*tags)
return __getobj__.push_tags(*tags) if __getobj__.respond_to?(:push_tags)
tags
end
|
51
52
53
54
55
|
# File 'lib/mbeditor/cable_log_filter.rb', line 51
def resolve_formatter
return Logger::Formatter.new unless __getobj__.respond_to?(:formatter)
__getobj__.formatter || Logger::Formatter.new
end
|
#tagged(*tags, &block) ⇒ Object
Tagged-logging compat — the block body still passes through the filter.
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/mbeditor/cable_log_filter.rb', line 67
def tagged(*tags, &block)
if __getobj__.respond_to?(:tagged)
tagged_logger = __getobj__.tagged(*tags, &block)
block ? tagged_logger : self.class.new(tagged_logger)
elsif block
block.call
else
self
end
end
|