Module: ConsoleDetective::Utils

Defined in:
lib/console_detective/utils.rb

Constant Summary collapse

LOGGER_PROC =
->(command) { ConsoleDetective::Utils.logger.info(ConsoleDetective.log_format.call(ConsoleDetective::Utils.get_tag, command)) }

Class Method Summary collapse

Class Method Details

.get_tagObject



11
12
13
14
# File 'lib/console_detective/utils.rb', line 11

def self.get_tag
  return @tag if ConsoleDetective.tag_memoization && @tag
  @tag = ConsoleDetective.log_tags.call
end

.log_command(command, immediately: false) ⇒ Object



16
17
18
19
# File 'lib/console_detective/utils.rb', line 16

def self.log_command(command, immediately: false)
  return Thread.new { ConsoleDetective::Utils::LOGGER_PROC.call(command) } unless immediately
  ConsoleDetective::Utils::LOGGER_PROC.call(command)
end

.loggerObject



7
8
9
# File 'lib/console_detective/utils.rb', line 7

def self.logger
  @logger ||= Logger.new(ConsoleDetective.log_file_name)
end