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 =
Both stream names, not just the editor one. Action Cable's broadcast line
("Broadcasting to : ") names only the stream, so a
channel-class pattern never matches it — and the collaboration stream
broadcasts on every keystroke and every cursor move, with the base64 CRDT
payload inlined. That floods a development log during pairing.
/Mbeditor::|mbeditor_editor|mbeditor_collab/
- CABLE_WEBSOCKET_REQUEST_PATTERN =
/(?:Started|Finished) "\/cable(?:\/[^\"]*)?" \[WebSocket\]/
Instance Method Summary
collapse
Instance Method Details
108
109
110
111
112
|
# File 'lib/mbeditor/cable_log_filter.rb', line 108
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.
90
91
92
93
94
|
# File 'lib/mbeditor/cable_log_filter.rb', line 90
def current_tags
return __getobj__.current_tags if __getobj__.respond_to?(:current_tags)
[]
end
|
#flush ⇒ Object
114
115
116
117
|
# File 'lib/mbeditor/cable_log_filter.rb', line 114
def flush
clear_tags!
__getobj__.flush if __getobj__.respond_to?(:flush)
end
|
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/mbeditor/cable_log_filter.rb', line 44
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
|
102
103
104
105
106
|
# File 'lib/mbeditor/cable_log_filter.rb', line 102
def pop_tags(count = 1)
return __getobj__.pop_tags(count) if __getobj__.respond_to?(:pop_tags)
[]
end
|
96
97
98
99
100
|
# File 'lib/mbeditor/cable_log_filter.rb', line 96
def push_tags(*tags)
return __getobj__.push_tags(*tags) if __getobj__.respond_to?(:push_tags)
tags
end
|
57
58
59
60
61
|
# File 'lib/mbeditor/cable_log_filter.rb', line 57
def resolve_formatter
return Logger::Formatter.new unless __getobj__.respond_to?(:formatter)
__getobj__.formatter || Logger::Formatter.new
end
|
#suppress_message?(message) ⇒ Boolean
#tagged(*tags, &block) ⇒ Object
Tagged-logging compat — the block body still passes through the filter.
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/mbeditor/cable_log_filter.rb', line 77
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
|