Class: Jiragit::Logger

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = nil) ⇒ Logger

Returns a new instance of Logger.



10
11
12
13
14
15
16
17
18
# File 'lib/jiragit/logger.rb', line 10

def initialize(path = nil)
  if path
    @path = path
  else
    @path = ".git/jiragit/jiragit.log"
  end
  FileUtils.mkdir_p directory
  super(@path)
end

Instance Attribute Details

#hookObject

Returns the value of attribute hook.



8
9
10
# File 'lib/jiragit/logger.rb', line 8

def hook
  @hook
end

Instance Method Details

#directoryObject



24
25
26
27
28
# File 'lib/jiragit/logger.rb', line 24

def directory
  dir = @path.gsub(/(^|\/)[^\/]*?$/,'')
  dir = "." if dir == ''
  dir
end

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



20
21
22
# File 'lib/jiragit/logger.rb', line 20

def format_message(severity, datetime, progname, msg)
  "#{datetime} #{@hook}: #{msg}\n"
end