Class: RemoteLogger::RingyLogger

Inherits:
Logger
  • Object
show all
Defined in:
lib/remote_logger/ringy_logger.rb

Overview

Subclass of RemoteLogger::Logger communicating via DRb protocol

Class Method Summary collapse

Methods inherited from Logger

#initialize

Constructor Details

This class inherits a constructor from RemoteLogger::Logger

Class Method Details

.find(options = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/remote_logger/ringy_logger.rb', line 28

def self.find(options = {})
  DRb.start_service

  name = options[:name] || LOGGER_NAME

  # Connecting to Ring server
  ring_server = Rinda::RingFinger.primary

  # Requesting logger service by name
  service = ring_server.read [:name, name.to_sym, nil, nil]
  service[2]
end

.start(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/remote_logger/ringy_logger.rb', line 6

def self.start(options = {})
  # Adding some security (disable remote eval)
  $SAFE = 1

  name = options[:name] || LOGGER_NAME

  # Creating logger instance
  logger = RemoteLogger::Logger.new options

  DRb.start_service

  # Raising new RingyDingy service
  logger.info "#{name}: Initializing service..." if options[:verbose]
  RingyDingy.new(logger, name.to_sym).run
  logger.info "#{name}: Service started" if options[:verbose]

  DRb.thread.join

  # Never reaches this point...
  logger.info "#{name}: Service finished" if options[:verbose]
end