Class: Pork::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/pork_sandwich/log.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output, options = {}) ⇒ Log

Returns a new instance of Log.



5
6
7
8
9
10
# File 'lib/pork_sandwich/log.rb', line 5

def initialize(output, options = {})
  @log = Logger.new(output)
  @log.level = Logger::INFO
  @researcher =  options[:researcher]? options[:researcher] : nil
  @project = options[:project]? options[:project] : nil
end

Instance Attribute Details

#logObject

Returns the value of attribute log.



3
4
5
# File 'lib/pork_sandwich/log.rb', line 3

def log
  @log
end

#outputObject

Returns the value of attribute output.



3
4
5
# File 'lib/pork_sandwich/log.rb', line 3

def output
  @output
end

#projectObject

Returns the value of attribute project.



3
4
5
# File 'lib/pork_sandwich/log.rb', line 3

def project
  @project
end

#researcherObject

Returns the value of attribute researcher.



3
4
5
# File 'lib/pork_sandwich/log.rb', line 3

def researcher
  @researcher
end

Instance Method Details

#write(message) ⇒ Object



12
13
14
# File 'lib/pork_sandwich/log.rb', line 12

def write(message)
  @log.info("#{@project ? @project + ', ' : ''}#{@researcher ? @researcher + ', ' : ''}#{Time.now.to_s} -- " + message)
end