Sha256: d2397a196a6bb320135ec357dbd233b29a749900762e85da4d5b62793ee019df

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

module RemoteLogger

  # Subclass of RemoteLogger::Logger communicating via DRb protocol
  class RingyLogger < Logger

    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

    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
remote_logger-0.0.5 lib/remote_logger/ringy_logger.rb