Class: DebugLog

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/debugLogger.rb

Instance Method Summary collapse

Constructor Details

#initializeDebugLog

Returns a new instance of DebugLog.



6
7
8
# File 'lib/debugLogger.rb', line 6

def initialize
  @log = File.open("mylog.txt", "a")
end

Instance Method Details

#log(information) ⇒ Object



9
10
11
12
# File 'lib/debugLogger.rb', line 9

def log(information)
  @log.puts(information)
  @log.flush
end

#logAsJson(information, name = nil) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/debugLogger.rb', line 23

def logAsJson information, name=nil
  @log.puts('=======================')
  if name != nil
    @log.puts("======== #{name} ========")
  end
  @log.puts(JSON.pretty_generate(information))
  @log.puts('----------------------------')
  @log.flush
end

#logInspect(information, name = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/debugLogger.rb', line 13

def logInspect information, name=nil
  @log.puts('=======================')
  if name != nil
    @log.puts("======== #{name} ========")
  end
  @log.puts(information.inspect)
  @log.puts('----------------------------')
  @log.flush
end