Sha256: caaca4deac7dc2f19a9d5a5b87fa6b47773e1f67918ab0f16af01341731ff332

Contents?: true

Size: 792 Bytes

Versions: 2

Compression:

Stored size: 792 Bytes

Contents

# :include: rdoc/GDC
#
# == Other Info
# 
# Version:: $Id$
# Author:: Colby Gutierrez-Kraybill <colby(at)astro.berkeley.edu>

require 'monitor'

module Log4r
  GDCNAME = "log4rGDC"
  $globalGDCLock = Monitor.new

  # See log4r-color/GDC.rb
  class GDC < Monitor
    private_class_method :new

    def self.clear()
      Thread.main[GDCNAME] = ""
    end

    def self.get()
      $globalGDCLock.synchronize do
	if ( Thread.main[GDCNAME] == nil ) then
	  Thread.main[GDCNAME] = $0
	end
      end
      return Thread.main[GDCNAME]
    end

    def self.set( a_name )
      if ( Thread.current != Thread.main ) then
	raise "Can only initialize Global Diagnostic Context from Thread.main" 
      end
      $globalGDCLock.synchronize do
	Thread.main[GDCNAME] = a_name
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
log4r-color-1.2.2 lib/log4r-color/GDC.rb
log4r-color-1.2 lib/log4r-color/GDC.rb