pvincent
2 months ago
4 changed files with 54 additions and 32 deletions
-
25lib/semantic/dev_loader.rb
-
19lib/semantic/subscribers/action_controller.rb
-
20lib/semantic/subscribers/action_view.rb
-
18lib/semantic/subscribers/log_subscriber.rb
@ -1,18 +1,28 @@ |
|||||
module Semantic |
module Semantic |
||||
module Subscribers |
module Subscribers |
||||
class ActionView < ActiveSupport::LogSubscriber |
|
||||
|
class ActionView < LogSubscriber |
||||
include AnsiColors |
include AnsiColors |
||||
|
|
||||
attr_reader :logger |
attr_reader :logger |
||||
|
|
||||
def initialize |
def initialize |
||||
short_name = self.class.to_s.split('::').last |
|
||||
@logger = SemanticLogger[short_name] |
|
||||
super |
|
||||
|
super(:action_view) |
||||
end |
end |
||||
|
|
||||
def render_partial(event) |
def render_partial(event) |
||||
logger.info('Rendered partial', event) |
|
||||
|
# logger.info('Rendered partial') |
||||
|
end |
||||
|
|
||||
|
def render_template(event) |
||||
|
logger.debug('Rendered template') |
||||
|
end |
||||
|
|
||||
|
def render_collection(event) |
||||
|
logger.debug('Rendered collection') |
||||
|
end |
||||
|
|
||||
|
def render_layout(event) |
||||
|
logger.debug('Rendered layout') |
||||
end |
end |
||||
end |
end |
||||
end |
end |
||||
|
@ -0,0 +1,18 @@ |
|||||
|
module Semantic |
||||
|
module Subscribers |
||||
|
class LogSubscriber |
||||
|
attr_reader :logger, :event_group |
||||
|
|
||||
|
def initialize(event_group) |
||||
|
@event_group = event_group |
||||
|
@logger = SemanticLogger[event_group.to_s] |
||||
|
end |
||||
|
|
||||
|
def any_hook(event) |
||||
|
logger.warn( |
||||
|
"#{@event_group} hook=<#{event.name.split('.')[0]}> needs a proper message handling!", event.payload.keys |
||||
|
) |
||||
|
end |
||||
|
end |
||||
|
end |
||||
|
end |
Write
Preview
Loading…
Cancel
Save
Reference in new issue