Class: Rpush::Logger

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLogger

Returns a new instance of Logger


5
6
7
8
9
10
11
12
# File 'lib/rpush/logger.rb', line 5

def initialize
  @internal_logger = Rpush.config.logger || setup_logger(open_logfile)
  @internal_logger.level = Rpush.config.log_level
rescue SystemCallError => e
  @internal_logger = nil
  error(e)
  error('Logging disabled.')
end

Instance Attribute Details

#internal_loggerObject (readonly)

Returns the value of attribute internal_logger


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

def internal_logger
  @internal_logger
end

Instance Method Details

#debug(msg, inline = false) ⇒ Object


14
15
16
# File 'lib/rpush/logger.rb', line 14

def debug(msg, inline = false)
  log(:debug, msg, inline)
end

#error(msg, inline = false) ⇒ Object


22
23
24
# File 'lib/rpush/logger.rb', line 22

def error(msg, inline = false)
  log(:error, msg, inline, 'ERROR', STDERR)
end

#info(msg, inline = false) ⇒ Object


18
19
20
# File 'lib/rpush/logger.rb', line 18

def info(msg, inline = false)
  log(:info, msg, inline)
end

#reopenObject


30
31
32
33
34
35
36
37
# File 'lib/rpush/logger.rb', line 30

def reopen
  if Rpush.config.logger
    Rpush.config.logger.reopen if Rpush.config.logger.respond_to?(:reopen)
  else
    @internal_logger.close
    @internal_logger = setup_logger(open_logfile)
  end
end

#warn(msg, inline = false) ⇒ Object


26
27
28
# File 'lib/rpush/logger.rb', line 26

def warn(msg, inline = false)
  log(:warn, msg, inline, 'WARNING', STDERR)
end