Class: Platform::Logger

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.debug(msg) ⇒ Object



46
47
48
# File 'lib/platform/logger.rb', line 46

def self.debug(msg)
  logger.debug(msg)
end

.error(msg) ⇒ Object



54
55
56
# File 'lib/platform/logger.rb', line 54

def self.error(msg)
  logger.error(msg)
end

.fatal(msg) ⇒ Object



58
59
60
# File 'lib/platform/logger.rb', line 58

def self.fatal(msg)
  logger.fatal(msg)
end

.info(msg) ⇒ Object



50
51
52
# File 'lib/platform/logger.rb', line 50

def self.info(msg)
  logger.info(msg)
end

.loggerObject



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/platform/logger.rb', line 29

def self.logger
  return Rails.logger unless Platform::Config.enable_logger?
  @logger ||= begin
    logfile_path = Platform::Config.log_path if Platform::Config.log_path.first == '/' 
    logfile_path = "#{Rails.root}/#{Platform::Config.log_path}" unless logfile_path
    logfile_dir = logfile_path.split("/")[0..-2].join("/")
    FileUtils.mkdir_p(logfile_dir) unless File.exist?(logfile_dir)
    logfile = File.open(logfile_path, 'a')
    logfile.sync = true
    Tr8n::Logger.new(logfile)
  end
end

Instance Method Details

#format_message(severity, timestamp, progname, msg) ⇒ Object



42
43
44
# File 'lib/platform/logger.rb', line 42

def format_message(severity, timestamp, progname, msg)
  "#{timestamp.to_formatted_s(:db)}: #{msg}\n" 
end