In Files

Parent

Log4r::MDC

See log4r/MDC.rb

Public Class Methods

check_thread_instance() click to toggle source
    # File lib/log4r/MDC.rb, line 19
19:     def self.check_thread_instance()
20:       # need to interlock here, so that if
21:       # another thread is entering this section
22:       # of code before the main thread does,
23:       # then the main thread copy of the MDC
24:       # is setup before then attempting to clone
25:       # it off
26:       if ( Thread.current[MDCNAME] == nil ) then
27:         $globalMDCLock.synchronize do 
28:           if ( Thread.main[MDCNAME] == nil ) then
29:             Thread.main[MDCNAME] = Hash.new
30:           end
31:           if ( Thread.current != Thread.main ) then
32:             Thread.current[MDCNAME] = Hash.new
33:             Thread.main[MDCNAME].each{ |k,v| Thread.current[MDCNAME][k] = v }
34:           end
35:         end
36:       end
37:     end
get( a_key ) click to toggle source
    # File lib/log4r/MDC.rb, line 39
39:     def self.get( a_key )
40:       self.check_thread_instance()
41:       Thread.current[MDCNAME].fetch(a_key, "");
42:     end
get_context() click to toggle source
    # File lib/log4r/MDC.rb, line 44
44:     def self.get_context()
45:       self.check_thread_instance()
46:       return Thread.current[MDCNAME].clone
47:     end
put( a_key, a_value ) click to toggle source
    # File lib/log4r/MDC.rb, line 49
49:     def self.put( a_key, a_value )
50:       self.check_thread_instance()
51:       Thread.current[MDCNAME][a_key] = a_value
52:     end
remove( a_key ) click to toggle source
    # File lib/log4r/MDC.rb, line 54
54:     def self.remove( a_key )
55:       self.check_thread_instance()
56:       Thread.current[MDCNAME].delete( a_key )
57:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.