Class: Log4r::NDC

Inherits:
Object
  • Object
show all
Defined in:
lib/log4r-color/NDC.rb

Overview

See log4r-color/NDC.rb

Class Method Summary collapse

Class Method Details

.check_thread_instanceObject



17
18
19
20
21
22
# File 'lib/log4r-color/NDC.rb', line 17

def self.check_thread_instance()
  if ( Thread.current[NDCNAME] == nil ) then
	Thread.current[NDCNAME] = Array.new
	Thread.current[NDCNAMEMAXDEPTH] = NDCDEFAULTMAXDEPTH
  end
end

.clearObject



24
25
26
27
# File 'lib/log4r-color/NDC.rb', line 24

def self.clear()
  self.check_thread_instance()
  Thread.current[NDCNAME].clear
end

.clone_stackObject



29
30
31
32
# File 'lib/log4r-color/NDC.rb', line 29

def self.clone_stack()
  self.check_thread_instance()
  return Thread.current[NDCNAME].clone
end

.getObject



51
52
53
54
# File 'lib/log4r-color/NDC.rb', line 51

def self.get()
  self.check_thread_instance
  return Thread.current[NDCNAME] * " "
end

.get_depthObject



34
35
36
37
# File 'lib/log4r-color/NDC.rb', line 34

def self.get_depth()
  self.check_thread_instance()
  return Thread.current[NDCNAME].length
end

.inherit(a_stack) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/log4r-color/NDC.rb', line 39

def self.inherit( a_stack )
  if ( a_stack.class == Array ) then
	if ( Thread.current[NDCNAME] != nil ) then
	  Thread.current[NDCNAME].clear
	  Thread.current[NDCNAME] = nil
	end
	Thread.current[NDCNAME] = a_stack
  else
	raise "Expecting Array in NDC.inherit"
  end
end

.peekObject



56
57
58
59
# File 'lib/log4r-color/NDC.rb', line 56

def self.peek()
  self.check_thread_instance()
  return Thread.current[NDCNAME].last
end

.popObject



61
62
63
64
# File 'lib/log4r-color/NDC.rb', line 61

def self.pop()
  self.check_thread_instance()
  return Thread.current[NDCNAME].pop
end

.push(value) ⇒ Object



66
67
68
69
70
71
# File 'lib/log4r-color/NDC.rb', line 66

def self.push( value )
  self.check_thread_instance()
  if ( Thread.current[NDCNAME].length < Thread.current[NDCNAMEMAXDEPTH] ) then
	Thread.current[NDCNAME].push( value )
  end
end

.removeObject



73
74
75
76
77
78
# File 'lib/log4r-color/NDC.rb', line 73

def self.remove()
  self.check_thread_instance()
  Thread.current[NDCNAME].clear
  Thread.current[NDCNAMEMAXDEPTH] = nil
  Thread.current[NDCNAME] = nil
end

.set_max_depth(max_depth) ⇒ Object



80
81
82
83
# File 'lib/log4r-color/NDC.rb', line 80

def self.set_max_depth( max_depth )
  self.check_thread_instance()
  Thread.current[NDCNAMEMAXDEPTH] = max_depth
end