Class: SciolyFF::Validator::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/sciolyff/validator/logger.rb

Overview

Prints extra information produced by validation process

Constant Summary collapse

ERROR =
0
WARN =
1
INFO =
2
DEBUG =
3

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(loglevel) ⇒ Logger

Returns a new instance of Logger.



13
14
15
16
# File 'lib/sciolyff/validator/logger.rb', line 13

def initialize(loglevel)
  @loglevel = loglevel
  flush
end

Instance Attribute Details

#logObject (readonly)

Returns the value of attribute log.



11
12
13
# File 'lib/sciolyff/validator/logger.rb', line 11

def log
  @log
end

Instance Method Details

#debug(msg) ⇒ Object



41
42
43
44
45
# File 'lib/sciolyff/validator/logger.rb', line 41

def debug(msg)
  return true if @loglevel < DEBUG

  @log << "DEBUG (possible intentional exception): #{msg}\n"
end

#error(msg) ⇒ Object



22
23
24
25
26
27
# File 'lib/sciolyff/validator/logger.rb', line 22

def error(msg)
  return false if @loglevel < ERROR

  @log << "ERROR (invalid SciolyFF): #{msg}\n"
  false # convenient for using logging the error as return value
end

#flushObject



18
19
20
# File 'lib/sciolyff/validator/logger.rb', line 18

def flush
  @log = String.new
end

#info(msg) ⇒ Object



35
36
37
38
39
# File 'lib/sciolyff/validator/logger.rb', line 35

def info(msg)
  return true if @loglevel < INFO

  @log << "INFO: #{msg}\n"
end

#warn(msg) ⇒ Object



29
30
31
32
33
# File 'lib/sciolyff/validator/logger.rb', line 29

def warn(msg)
  return true if @loglevel < WARN

  @log << "WARNING (still valid SciolyFF): #{msg}\n"
end