Class: Imap::Backup::Logger

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/imap/backup/logger.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLogger

Returns a new instance of Logger.



37
38
39
40
# File 'lib/imap/backup/logger.rb', line 37

def initialize
  @logger = ::Logger.new($stdout)
  $stdout.sync = true
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



35
36
37
# File 'lib/imap/backup/logger.rb', line 35

def logger
  @logger
end

Class Method Details

.loggerObject



11
12
13
# File 'lib/imap/backup/logger.rb', line 11

def self.logger
  Logger.instance.logger
end

.sanitize_stderrObject



25
26
27
28
29
30
31
32
33
# File 'lib/imap/backup/logger.rb', line 25

def self.sanitize_stderr
  sanitizer = Sanitizer.new($stdout)
  previous_stderr = $stderr
  $stderr = sanitizer
  yield
ensure
  sanitizer.flush
  $stderr = previous_stderr
end

.setup_logging(config = Configuration.new) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/imap/backup/logger.rb', line 15

def self.setup_logging(config = Configuration.new)
  logger.level =
    if config.debug?
      ::Logger::Severity::DEBUG
    else
      ::Logger::Severity::ERROR
    end
  Net::IMAP.debug = config.debug?
end