Class: HrrRbSsh::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/hrr_rb_ssh/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.



22
23
24
# File 'lib/hrr_rb_ssh/logger.rb', line 22

def initialize name
  @name = name
end

Class Method Details

.initialize(logger) ⇒ Object



9
10
11
# File 'lib/hrr_rb_ssh/logger.rb', line 9

def initialize logger
  @@logger = logger
end

.initialized?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/hrr_rb_ssh/logger.rb', line 17

def initialized?
  @@logger != nil
end

.uninitializeObject



13
14
15
# File 'lib/hrr_rb_ssh/logger.rb', line 13

def uninitialize
  @@logger = nil
end

Instance Method Details

#debugObject



50
51
52
53
54
# File 'lib/hrr_rb_ssh/logger.rb', line 50

def debug
  if @@logger
    @@logger.debug { "p#{Process.pid}.t#{Thread.current.object_id}: #{@name}: #{yield}" }
  end
end

#errorObject



32
33
34
35
36
# File 'lib/hrr_rb_ssh/logger.rb', line 32

def error
  if @@logger
    @@logger.error { "p#{Process.pid}.t#{Thread.current.object_id}: #{@name}: #{yield}" }
  end
end

#fatalObject



26
27
28
29
30
# File 'lib/hrr_rb_ssh/logger.rb', line 26

def fatal
  if @@logger
    @@logger.fatal { "p#{Process.pid}.t#{Thread.current.object_id}: #{@name}: #{yield}" }
  end
end

#infoObject



44
45
46
47
48
# File 'lib/hrr_rb_ssh/logger.rb', line 44

def info
  if @@logger
    @@logger.info { "p#{Process.pid}.t#{Thread.current.object_id}: #{@name}: #{yield}" }
  end
end

#warnObject



38
39
40
41
42
# File 'lib/hrr_rb_ssh/logger.rb', line 38

def warn
  if @@logger
    @@logger.warn { "p#{Process.pid}.t#{Thread.current.object_id}: #{@name}: #{yield}" }
  end
end