Module: Rcal::Util::Loggable

Defined in:
lib/rcal/util/loggable.rb

Overview

Simple logging support.

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) default_logger

Returns the default logger. Unless it has been set, this logs to STDOUT, and is at level DEBUG.



9
10
11
# File 'lib/rcal/util/loggable.rb', line 9

def self.default_logger
  @@default_logger ||= initialize_default_logger
end

+ (Object) default_logger=(logger)

Sets the default logger.

Returns nil.

Raises ArgumentError unless logger is a Logger.

Raises:

  • (ArgumentError)


18
19
20
21
22
# File 'lib/rcal/util/loggable.rb', line 18

def self.default_logger=(logger)
  raise ArgumentError.new("#{logger} is not a Logger") unless logger.kind_of?(Logger)
  @@default_logger = logger
  nil
end

Instance Method Details

- (Object) logger

Returns the custom logger if set, otherwise Rcal::Util::Loggable.default_logger.



25
26
27
# File 'lib/rcal/util/loggable.rb', line 25

def logger
  @logger || Rcal::Util::Loggable.default_logger
end

- (Object) logger=(logger)

Sets a custom logger.

Returns nil.

Raises ArgumentError unless logger is a Logger.

Raises:

  • (ArgumentError)


34
35
36
37
38
# File 'lib/rcal/util/loggable.rb', line 34

def logger=(logger)
  raise ArgumentError.new("#{logger} is not a Logger") unless logger.kind_of?(Logger)
  @logger = logger
  nil
end