Class: Log4r::MDC

### Home Classes Methods

### In Files

- lib/log4r/MDC.rb

### Parent

Monitor

### Methods

- ::check_thread_instance
- ::get
- ::get_context
- ::put
- ::remove

### Files

- GDC
- MDC
- NDC
- configurator
- emailoutputter
- formatter
- log4jxmlformatter
- log4r
- logger
- logserver
- outputter
- patternformatter
- scribeoutputter
- syslogoutputter
- win32eventoutputter
- yamlconfigurator

### Class/Module Index

Quicksearch

- Log4r
- Log4r::BasicFormatter
- Log4r::ConfigError
- Log4r::Configurator
- Log4r::DateFileOutputter
- Log4r::DefaultFormatter
- Log4r::EmailOutputter
- Log4r::FileOutputter
- Log4r::Formatter
- Log4r::GDC
- Log4r::IOOutputter
- Log4r::Log4jXmlFormatter
- Log4r::Log4rTools
- Log4r::LogEvent
- Log4r::LogServer
- Log4r::Logger
- Log4r::MDC
- Log4r::NDC
- Log4r::ObjectFormatter
- Log4r::Outputter
- Log4r::PatternFormatter
- Log4r::RemoteOutputter
- Log4r::RollingFileOutputter
- Log4r::RootLogger
- Log4r::ScribeOutputter
- Log4r::SimpleFormatter
- Log4r::StderrOutputter
- Log4r::StdoutOutputter
- Log4r::SyslogOutputter
- Log4r::UDPOutputter
- Log4r::YamlConfigurator
- REXML
- Object

No matching classes.

# Log4r::MDC

See log4r/MDC.rb

### Public Class Methods

check_thread_instance() click to toggle source

    # File lib/log4r/MDC.rb, line 19
    def self.check_thread_instance()
      # need to interlock here, so that if
      # another thread is entering this section
      # of code before the main thread does,
      # then the main thread copy of the MDC
      # is setup before then attempting to clone
      # it off
      if ( Thread.current[MDCNAME] == nil ) then
        $globalMDCLock.synchronize do
          if ( Thread.main[MDCNAME] == nil ) then
            Thread.main[MDCNAME] = Hash.new
          end
          if ( Thread.current != Thread.main ) then
            Thread.current[MDCNAME] = Hash.new
            Thread.main[MDCNAME].each{ |k,v| Thread.current[MDCNAME][k] = v }
          end
        end
      end
    end

get( a_key ) click to toggle source

    # File lib/log4r/MDC.rb, line 39
    def self.get( a_key )
      self.check_thread_instance()
      Thread.current[MDCNAME].fetch(a_key, "");
    end

get_context() click to toggle source

    # File lib/log4r/MDC.rb, line 44
    def self.get_context()
      self.check_thread_instance()
      return Thread.current[MDCNAME].clone
    end

put( a_key, a_value ) click to toggle source

    # File lib/log4r/MDC.rb, line 49
    def self.put( a_key, a_value )
      self.check_thread_instance()
      Thread.current[MDCNAME][a_key] = a_value
    end

remove( a_key ) click to toggle source

    # File lib/log4r/MDC.rb, line 54
    def self.remove( a_key )
      self.check_thread_instance()
      Thread.current[MDCNAME].delete( a_key )
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.