~ubuntu-branches/ubuntu/trusty/zonecheck/trusty

« back to all changes in this revision

Viewing changes to zc/dbg.rb

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Delafond
  • Date: 2010-07-08 12:55:39 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20100708125539-gazuzu1eb58l3tot
Tags: 3.0.2-1
* New upstream release (Closes: #587419).
* Updated watch file.
* Bumped up Standards revision.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# $Id: dbg.rb,v 1.29 2010/06/07 08:51:25 chabannf Exp $
 
1
# $Id: dbg.rb,v 1.30 2010/06/23 12:03:59 chabannf Exp $
2
2
 
3
3
4
4
# CONTACT     : zonecheck@nic.fr
5
5
# AUTHOR      : Stephane D'Alu <sdalu@nic.fr>
6
6
#
7
7
# CREATED     : 2002/09/16 13:31:29
8
 
# REVISION    : $Revision: 1.29 $ 
9
 
# DATE        : $Date: 2010/06/07 08:51:25 $
 
8
# REVISION    : $Revision: 1.30 $ 
 
9
# DATE        : $Date: 2010/06/23 12:03:59 $
10
10
#
11
11
# CONTRIBUTORS: (see also CREDITS file)
12
12
#
80
80
        @output = output
81
81
        @lvl    = lvl
82
82
        @mutex  = Mutex::new
 
83
  @old_messages = []
83
84
        msg(DBG) { "Debugger initialized at level %0x" % @lvl }
84
85
    end
85
86
 
135
136
                      end
136
137
            set_trace_func(dbgfunc)
137
138
        end
 
139
            failed_messages = @old_messages
 
140
      
 
141
      @mutex.synchronize {
 
142
        @old_messages = []
 
143
      }
 
144
      failed_messages.each {|type,msg|
 
145
        msg(type,msg) unless msg.nil?
 
146
      }
138
147
    end
139
148
 
140
149
 
144
153
    #       second argument, as this will provide a lazy evaluation
145
154
    #
146
155
    def msg(type, arg=nil)
147
 
        return unless enabled?(type)
148
156
 
149
157
        unless block_given? ^ !arg.nil?
150
158
            raise ArgumentError, 'either string or block should be given'
151
159
        end
152
160
        arg = yield if block_given?
153
 
 
 
161
        
 
162
        arg = arg.to_s
 
163
  unless enabled?(type)
 
164
    @mutex.synchronize {
 
165
      @old_messages << [type,arg]
 
166
          }
 
167
          return 
 
168
        end
154
169
        @mutex.synchronize {
155
170
            case arg
156
171
            when Array