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.2.beta.2 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.2.beta.1 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.1 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-5.0.0 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-1.0.2 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-1.0.1 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-1.0.0 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kinetic_sdk-0.1.1 gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb
kontena-websocket-client-0.1.1 lib/kontena/websocket/logging.rb
kontena-websocket-client-0.1.0 lib/kontena/websocket/logging.rb
kontena-websocket-client-0.0.1 lib/kontena/websocket/logging.rb
kontena-websocket-client-0.0.0 lib/kontena/websocket/logging.rb