Module: Logging

Defined in:
lib/mkmfmf.rb

Overview

This is a custom logging module. It generates an mkmf.log file when you run your extconf.rb script. This can be useful for debugging unexpected failures.

This module and its associated methods are meant for internal use only.

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.quietObject

Returns the value of attribute quiet.



293
294
295
# File 'lib/mkmfmf.rb', line 293

def quiet
  @quiet
end

Class Method Details

.log_openObject



246
247
248
249
# File 'lib/mkmfmf.rb', line 246

def self::log_open
  @log ||= File::open(@logfile, 'wb')
  @log.sync = true
end

.logfile(file) ⇒ Object



266
267
268
269
270
271
272
273
# File 'lib/mkmfmf.rb', line 266

def self::logfile file
  @logfile = file
  if @log and not @log.closed?
    @log.flush
    @log.close
    @log = nil
  end
end

.message(*s) ⇒ Object



261
262
263
264
# File 'lib/mkmfmf.rb', line 261

def self::message(*s)
  log_open
  @log.printf(*s)
end

.openObject



251
252
253
254
255
256
257
258
259
# File 'lib/mkmfmf.rb', line 251

def self::open
  log_open
  $stderr.reopen(@log)
  $stdout.reopen(@log)
  yield
ensure
  $stderr.reopen(@orgerr)
  $stdout.reopen(@orgout)
end

.postponeObject



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/mkmfmf.rb', line 275

def self::postpone
  tmplog = "mkmftmp#{@postpone += 1}.log"
  open do
    log, *save = @log, @logfile, @orgout, @orgerr
    @log, @logfile, @orgout, @orgerr = nil, tmplog, log, log
    begin
      log.print(open {yield})
    ensure
      @log.close
      File::open(tmplog) {|t| FileUtils.copy_stream(t, log)}
      @log, @logfile, @orgout, @orgerr = log, *save
      @postpone -= 1
      rm_f tmplog
    end
  end
end