Sha256: 0cb5f0e8aee41783c89b29e56c6650c62bdf4a1902a766da24f3728086edb2ac

Contents?: true

Size: 1.43 KB

Versions: 4

Compression:

Stored size: 1.43 KB

Contents

#--
# Copyright (c) 2008-2012 David Kellum
#
# Licensed under the Apache License, Version 2.0 (the "License"); you
# may not use this file except in compliance with the License.  You
# may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.  See the License for the specific language governing
# permissions and limitations under the License.
#++

require 'rjack-slf4j'

module RJack::SLF4J

  # Mapped Diagnostic Context support module
  #
  # Note that this optional module can only be loaded after a output
  # adapter has been loaded.  Otherwise the following output is
  # printed and Exception will be thrown:
  #
  #   SLF4J: Failed to load class "org.slf4j.impl.StaticMDCBinder".
  #   SLF4J: See http://www.slf4j.org/codes.html#no_static_mdc_binder for further details.
  #   java.lang.NoClassDefFoundError: org/slf4j/impl/StaticMDCBinder
  #
  module MDC

    # Get value associated with key, or nil.
    def self.[]( key )
      org.slf4j.MDC::get( key.to_s )
    end

    # Associate val with key, or remove key is value is nil.
    def self.[]=( key, val )
      if val
        org.slf4j.MDC::put( key.to_s, val.to_s )
      else
        org.slf4j.MDC::remove( key.to_s )
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rjack-slf4j-1.7.2.0-java lib/rjack-slf4j/mdc.rb
rjack-slf4j-1.7.0.0-java lib/rjack-slf4j/mdc.rb
rjack-slf4j-1.6.6.0-java lib/rjack-slf4j/mdc.rb
rjack-slf4j-1.6.5.0-java lib/rjack-slf4j/mdc.rb