lib/dry/monitor/sql/logger.rb in dry-monitor-0.0.3 vs lib/dry/monitor/sql/logger.rb in dry-monitor-0.1.0

- old
+ new

@@ -1,10 +1,13 @@ require 'dry-configurable' require 'rouge' +require 'dry/monitor/notifications' module Dry module Monitor + Notifications.register_event(:sql) + module SQL class Logger extend Dry::Configurable setting :theme, Rouge::Themes::Gruvbox.new @@ -24,11 +27,11 @@ @lexer = Rouge::Lexers::SQL.new @template = config.message_template end def subscribe(notifications) - notifications.event(:sql).subscribe(:sql) do |time, id, payload| - log_query(time, payload[:name], payload[:query]) + notifications.subscribe(:sql) do |time:, name:, query:| + log_query(time, name, query) end end def log_query(time, name, query) logger.info template % [name.inspect, time, colorize(query)]