Class: Log4r::NDC
- Inherits:
-
Object
- Object
- Log4r::NDC
- Defined in:
- lib/log4r/NDC.rb
Overview
See log4r/NDC.rb
Class Method Summary collapse
- .check_thread_instance ⇒ Object
- .clear ⇒ Object
- .clone_stack ⇒ Object
- .get ⇒ Object
- .get_depth ⇒ Object
- .inherit(a_stack) ⇒ Object
- .peek ⇒ Object
- .pop ⇒ Object
- .push(value) ⇒ Object
- .remove ⇒ Object
- .set_max_depth(max_depth) ⇒ Object
Class Method Details
.check_thread_instance ⇒ Object
17 18 19 20 21 22 |
# File 'lib/log4r/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 |
.clear ⇒ Object
24 25 26 27 |
# File 'lib/log4r/NDC.rb', line 24 def self.clear() self.check_thread_instance() Thread.current[NDCNAME].clear end |
.clone_stack ⇒ Object
29 30 31 32 |
# File 'lib/log4r/NDC.rb', line 29 def self.clone_stack() self.check_thread_instance() return Thread.current[NDCNAME].clone end |
.get ⇒ Object
51 52 53 54 |
# File 'lib/log4r/NDC.rb', line 51 def self.get() self.check_thread_instance return Thread.current[NDCNAME] * " " end |
.get_depth ⇒ Object
34 35 36 37 |
# File 'lib/log4r/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/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 |
.peek ⇒ Object
56 57 58 59 |
# File 'lib/log4r/NDC.rb', line 56 def self.peek() self.check_thread_instance() return Thread.current[NDCNAME].last end |
.pop ⇒ Object
61 62 63 64 |
# File 'lib/log4r/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/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 |
.remove ⇒ Object
73 74 75 76 77 78 |
# File 'lib/log4r/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/NDC.rb', line 80 def self.set_max_depth( max_depth ) self.check_thread_instance() Thread.current[NDCNAMEMAXDEPTH] = max_depth end |