Class: Moodle2CC::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/moodle2cc/logger.rb

Class Method Summary collapse

Class Method Details

.add_warning(message, exception) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/moodle2cc/logger.rb', line 11

def self.add_warning(message, exception)
  if logger.respond_to? :add_warning
    logger.add_warning(message, exception)
  elsif logger.respond_to? :warn
    log = "#{message}\n    #{exception.message}\n"
    if exception.backtrace
      exception.backtrace.each { |line| log << "    #{line}\n" }
    end
    logger.warn log
  end
end

.loggerObject



3
4
5
# File 'lib/moodle2cc/logger.rb', line 3

def self.logger
  Thread.current[:__moodle2cc_logger__] || ::Logger.new(STDOUT)
end

.logger=(logger) ⇒ Object



7
8
9
# File 'lib/moodle2cc/logger.rb', line 7

def self.logger=(logger)
  Thread.current[:__moodle2cc_logger__] = logger
end