Class: Rpush::Logger

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

Instance Method Summary collapse

Constructor Details

#initializeLogger

Returns a new instance of Logger.



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

def initialize
  FileUtils.mkdir_p(File.dirname(Rpush.config.log_file))
  log = File.open(Rpush.config.log_file, 'a')
  log.sync = true
  setup_logger(log)
rescue Errno::ENOENT, Errno::EPERM => e
  @logger = nil
  error(e)
  error('Logging disabled.')
end

Instance Method Details

#error(msg, inline = false) ⇒ Object



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

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

#info(msg, inline = false) ⇒ Object



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

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

#warn(msg, inline = false) ⇒ Object



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

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