Class: IRBTracker::IRBLoggable

Inherits:
Module
  • Object
show all
Defined in:
lib/irb_tracker/irb_loggable.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(service_name = 'undefined') ⇒ IRBLoggable

Returns a new instance of IRBLoggable.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/irb_tracker/irb_loggable.rb', line 8

def initialize(service_name = 'undefined')
  logger = LoggerFactory.create service_name
  # rubocop:disable Style/RedundantBegin
  define_method :evaluate do |*args, &block|
    begin
      result = super(*args, &block)
      logger.info(source: 'irb_console',
                  user: LDAPLogin.current_user,
                  command: args.first.chomp,
                  result: inspect_last_value.chomp)
      result
    rescue StandardError => e
      logger.error(source: 'irb_console',
                   user: LDAPLogin.current_user,
                   command: args.first.chomp,
                   error: e.message,
                   error_trace: e.backtrace.inspect)
      raise e
    end
  end
  # rubocop:enable Style/RedundantBegin
end