Module: Siba::LoggerPlug

Overview

Used to inject “logger” to classes that include this module

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.closeObject



23
24
25
26
27
28
29
# File 'lib/siba/logger_plug.rb', line 23

def close
  @logger.close if LoggerPlug.opened?
  @logger = nil
  SibaLogger.quiet = false
  SibaLogger.verbose = false
  SibaLogger.no_log = false
end

.create(name, path_to_log_file, show_start_message = true) ⇒ Object

Raises:



18
19
20
21
# File 'lib/siba/logger_plug.rb', line 18

def create(name, path_to_log_file, show_start_message = true)
  raise Siba::Error, "Log is already created" if LoggerPlug.opened?
  @logger = SibaLogger.new name, path_to_log_file, show_start_message
end

.loggerObject

Raises:



13
14
15
16
# File 'lib/siba/logger_plug.rb', line 13

def logger
  raise Siba::Error, "Log is not created" unless LoggerPlug.opened?
  @logger
end

.opened?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/siba/logger_plug.rb', line 31

def opened?
  !@logger.nil?
end

Instance Method Details

#loggerObject



8
9
10
# File 'lib/siba/logger_plug.rb', line 8

def logger
  LoggerPlug.logger
end