Sha256: aad47b0c9000b179f46343428a126db4526ac1ff43b090a071b6fea79caa49cf
Contents?: true
Size: 1.97 KB
Versions: 4
Compression:
Stored size: 1.97 KB
Contents
class Eco::API::Common::Loaders::Workflow::Mailer < Eco::API::Common::Loaders::Workflow ORG = 'your organization'.freeze TRACE_COUNT = 3 inheritable_class_vars :config_block config_block do puts "running from class #{self}" exception do |err, io| self.error = err log(:debug) { err.patch_full_message } workflow.run(:close, io: io) end after(:close) do |_wf, io| next if options.dig(:workflow, :no_email) next unless session.mailer? next if session.config.dry_run? next unless session.config.run_mode_remote? next unless some_update?(io) || error? subject = base_subject if session.job_groups.empty? && error? subject = "#{subject} - Exception!" session.mail(subject: subject, body: errors_n_warnings(io)) else subject = "#{subject} & Errors" if session.job_groups.errors? subject = "#{subject} - Exception!" if error? msg = "#{session.summary}\n" msg += errors_n_warnings(io) session.mail(subject: subject, body: msg) unless msg.strip.empty? end end end class << self attr_accessor :error def org_name self::ORG end def base_subject "#{org_name} (#{active_enviro}) at #{Time.now.iso8601}" end def some_update?(io) cli.config.usecases.active(io: io).any? do |usecase, data| [:transform, :sync].any? { |type| usecase.type == type } end end def error? !!error end def errors_n_warnings(io) [error_message, log_err_n_warn(io)].join("\n") end def log_err_n_warn(io) warn_errors = io.logger.cache.logs(level: [:error, :warn]) return if warn_errors.empty? "WARNINGS & ERRORS:\n#{warn_errors.join('')}\n" end def error_message error&.patch_full_message(trace_count: 3) end def trace_count self::TRACE_COUNT end end end
Version data entries
4 entries across 4 versions & 1 rubygems