Sha256: ca9421e2b5802ef1b78f1d9ea59d40a98533e303b895584eb23b45084625e2c1

Contents?: true

Size: 1.28 KB

Versions: 32

Compression:

Stored size: 1.28 KB

Contents

require 'logger'

module Kontena::Websocket
  module Logging
    def self.initialize_logger(log_target = STDOUT, log_level = Logger::INFO)
      @logger = Logger.new(log_target)
      @logger.level = log_level
      @logger
    end

    def self.logger
      defined?(@logger) ? @logger : initialize_logger
    end

    def self.logger=(log)
      @logger = (log ? log : Logger.new('/dev/null'))
    end

    # @return [Logger]
    def logger
      Kontena::Websocket::Logging.logger
    end

    # Prefix for log messages, defaults to class name
    #
    # @return [String]
    def logging_prefix
      self.class.name
    end

    # Send a debug message
    # @param message [String]
    def debug(message = nil, &block)
      logger.add(Logger::DEBUG, message, logging_prefix, &block)
    end

    # Send a info message
    # @param message [String]
    def info(message = nil, &block)
      logger.add(Logger::INFO, message, logging_prefix, &block)
    end

    # Send a warning message
    # @param message [String]
    def warn(message = nil, &block)
      logger.add(Logger::WARN, message, logging_prefix, &block)
    end

    # Send an error message
    # @param message [String]
    def error(message = nil, &block)
      logger.add(Logger::ERROR, message, logging_prefix, &block)
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
kinetic_sdk-5.0.19 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.18 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.17 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.16 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.15 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.14 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.13 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.12 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.11 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.10 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.9 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.8 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.7 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.6 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.5 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.4 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.3 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.2 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.2.beta.4 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.2.beta.3 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb