Class: Rubyang::Database::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyang/database/logger.rb

Constant Summary collapse

@@logger =
nil

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Logger

Returns a new instance of Logger.



23
24
25
# File 'lib/rubyang/database/logger.rb', line 23

def initialize name
  @name = name
end

Class Method Details

.initialize(logger) ⇒ Object



10
11
12
# File 'lib/rubyang/database/logger.rb', line 10

def initialize logger
  @@logger = logger
end

.initialized?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/rubyang/database/logger.rb', line 18

def initialized?
  @@logger != nil
end

.uninitializeObject



14
15
16
# File 'lib/rubyang/database/logger.rb', line 14

def uninitialize
  @@logger = nil
end

Instance Method Details

#debugObject



51
52
53
54
55
# File 'lib/rubyang/database/logger.rb', line 51

def debug
  if @@logger
    @@logger.debug { "#{@name}: #{yield}" }
  end
end

#errorObject



33
34
35
36
37
# File 'lib/rubyang/database/logger.rb', line 33

def error
  if @@logger
    @@logger.error { "#{@name}: #{yield}" }
  end
end

#fatalObject



27
28
29
30
31
# File 'lib/rubyang/database/logger.rb', line 27

def fatal
  if @@logger
    @@logger.fatal { "#{@name}: #{yield}" }
  end
end

#infoObject



45
46
47
48
49
# File 'lib/rubyang/database/logger.rb', line 45

def info
  if @@logger
    @@logger.info { "#{@name}: #{yield}" }
  end
end

#warnObject



39
40
41
42
43
# File 'lib/rubyang/database/logger.rb', line 39

def warn
  if @@logger
    @@logger.warn { "#{@name}: #{yield}" }
  end
end