Class: Bizside::Audit::Logger

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/bizside/audit/logger.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLogger

Returns a new instance of Logger.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bizside/audit/logger.rb', line 14

def initialize
  path = file_path
  FileUtils.mkdir_p( File.dirname(path) )
  file = File.open(path, 'a')
  file.sync = true

  @logger = ::Logger.new(file)
  @logger.formatter = proc do |severity, datetime, progname, msg|
    "#{msg}\n"
  end
end

Class Method Details

.loggerObject



10
11
12
# File 'lib/bizside/audit/logger.rb', line 10

def self.logger
  self.instance
end

Instance Method Details

#file_pathObject



30
31
32
# File 'lib/bizside/audit/logger.rb', line 30

def file_path
  File.join('log', 'audit.log')
end

#record(info = {}) ⇒ Object



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

def record(info = {})
  @logger.info LTSV.dump(info)
end