Class: Patch::Log

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

Overview

Logging

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Log.

Parameters:

  • out (IO)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :show (Array<Symbol>)


9
10
11
12
13
# File 'lib/patch/log.rb', line 9

def initialize(out, options = {})
  @out = out
  @start = Time.now
  populate_level(options)
end

Instance Method Details

#exception(exception) ⇒ String Also known as: error

Output an exception

Parameters:

  • exception (String)

Returns:

  • (String)


38
39
40
41
42
43
44
# File 'lib/patch/log.rb', line 38

def exception(exception)
  if @exception
    message = format(exception.message, :type => :exception)
    @out.puts(message)
  end
  exception
end

#pathObject



15
16
17
# File 'lib/patch/log.rb', line 15

def path
  @out.path
end

#puts(message) ⇒ String Also known as: info

Output an info message

Parameters:

  • message (String)

Returns:

  • (String)


28
29
30
31
32
# File 'lib/patch/log.rb', line 28

def puts(message)
  message = format(message, :type => :info)
  @out.puts(message) if @info
  message
end

#timeTime

The current time since startup

Returns:

  • (Time)


21
22
23
# File 'lib/patch/log.rb', line 21

def time
  Time.now - @start
end