Module Net::SSH::Loggable
In: lib/net/ssh/loggable.rb
lib/net/ssh/loggable.rb

A simple module to make logging easier to deal with. It assumes that the logger instance (if not nil) quacks like a Logger object (in Ruby‘s standard library). Although used primarily internally by Net::SSH, it can easily be used to add Net::SSH-like logging to your own programs.

  class MyClass
    include Net::SSH::Loggable
  end

  Net::SSH.start(...) do |ssh|
    obj = MyClass.new
    obj.logger = ssh.logger
    ...
  end

Methods

debug   debug   error   error   fatal   fatal   info   info   lwarn   lwarn  

Attributes

logger  [RW]  The logger instance that will be used to log messages. If nil, nothing will be logged.
logger  [RW]  The logger instance that will be used to log messages. If nil, nothing will be logged.

Public Instance methods

Displays the result of yielding if the log level is Logger::DEBUG or greater.

[Source]

    # File lib/net/ssh/loggable.rb, line 24
24:     def debug
25:       logger.add(Logger::DEBUG, nil, facility) { yield } if logger
26:     end

Displays the result of yielding if the log level is Logger::DEBUG or greater.

[Source]

    # File lib/net/ssh/loggable.rb, line 24
24:     def debug
25:       logger.add(Logger::DEBUG, nil, facility) { yield } if logger
26:     end

Displays the result of yielding if the log level is Logger:ERROR or greater.

[Source]

    # File lib/net/ssh/loggable.rb, line 42
42:     def error
43:       logger.add(Logger::ERROR, nil, facility) { yield } if logger
44:     end

Displays the result of yielding if the log level is Logger:ERROR or greater.

[Source]

    # File lib/net/ssh/loggable.rb, line 42
42:     def error
43:       logger.add(Logger::ERROR, nil, facility) { yield } if logger
44:     end

Displays the result of yielding if the log level is Logger::FATAL or greater.

[Source]

    # File lib/net/ssh/loggable.rb, line 48
48:     def fatal
49:       logger.add(Logger::FATAL, nil, facility) { yield } if logger
50:     end

Displays the result of yielding if the log level is Logger::FATAL or greater.

[Source]

    # File lib/net/ssh/loggable.rb, line 48
48:     def fatal
49:       logger.add(Logger::FATAL, nil, facility) { yield } if logger
50:     end

Displays the result of yielding if the log level is Logger::INFO or greater.

[Source]

    # File lib/net/ssh/loggable.rb, line 30
30:     def info
31:       logger.add(Logger::INFO, nil, facility) { yield } if logger
32:     end

Displays the result of yielding if the log level is Logger::INFO or greater.

[Source]

    # File lib/net/ssh/loggable.rb, line 30
30:     def info
31:       logger.add(Logger::INFO, nil, facility) { yield } if logger
32:     end

Displays the result of yielding if the log level is Logger::WARN or greater. (Called lwarn to avoid shadowing with Kernel#warn.)

[Source]

    # File lib/net/ssh/loggable.rb, line 36
36:     def lwarn
37:       logger.add(Logger::WARN, nil, facility) { yield } if logger
38:     end

Displays the result of yielding if the log level is Logger::WARN or greater. (Called lwarn to avoid shadowing with Kernel#warn.)

[Source]

    # File lib/net/ssh/loggable.rb, line 36
36:     def lwarn
37:       logger.add(Logger::WARN, nil, facility) { yield } if logger
38:     end

[Validate]