Sha256: 3a0260eba1e9a74a4d046f61e8d9e6ece65137de0680cf9ecaffa0f30cbe0f73

Contents?: true

Size: 977 Bytes

Versions: 4

Compression:

Stored size: 977 Bytes

Contents

# -*- coding: utf-8 -*-
require 'logger'

module Dcmgr
  module Logger

    # for passenger, messages in STDOUT are not appeared in
    # error.log. $> is changed in initializers/logger.rb as per the
    # server environment. so that here also refers $> instead of STDOUT or
    # STDERR constant.
    @logdev = ::Logger::LogDevice.new($>)

    def self.default_logdev
      @logdev
    end

    # Factory method for ::Logger
    def self.create(name=nil)
      l = ::Logger.new(default_logdev)
      l.progname = name
      l
    end
    
    def self.included(klass)
      klass.class_eval {

        @class_logger = Logger.create(self.to_s.split('::').last)

        def self.logger
          @class_logger
        end

        def logger
          self.class.logger
        end

        def self.logger_name
          @class_logger.progname
        end

        def self.logger_name=(name)
          @class_logger.progname = name
        end
      }
    end
    
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
wakame-vdc-agents-11.12.0 lib/dcmgr/logger.rb
wakame-vdc-dcmgr-11.12.0 lib/dcmgr/logger.rb
wakame-vdc-agents-11.06.0 lib/dcmgr/logger.rb
wakame-vdc-dcmgr-11.06.0 lib/dcmgr/logger.rb