Module: MakeMakefile::Logging

Defined in:
lib/mkmf.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.



365
366
367
# File 'lib/mkmf.rb', line 365

def quiet
  @quiet
end

Class Method Details

.log_closeObject



339
340
341
342
343
344
345
# File 'lib/mkmf.rb', line 339

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

.log_openObject



310
311
312
313
# File 'lib/mkmf.rb', line 310

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

.log_opened?Boolean

Returns:

  • (Boolean)


315
316
317
# File 'lib/mkmf.rb', line 315

def self::log_opened?
  @log and not @log.closed?
end

.logfile(file) ⇒ Object



334
335
336
337
# File 'lib/mkmf.rb', line 334

def self::logfile file
  @logfile = file
  log_close
end

.message(*s) ⇒ Object



329
330
331
332
# File 'lib/mkmf.rb', line 329

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

.openObject



319
320
321
322
323
324
325
326
327
# File 'lib/mkmf.rb', line 319

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

.postponeObject



347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/mkmf.rb', line 347

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 @log})
    ensure
      @log.close if @log and not @log.closed?
      File::open(tmplog) {|t| FileUtils.copy_stream(t, log)} if File.exist?(tmplog)
      @log, @logfile, @orgout, @orgerr = log, *save
      @postpone -= 1
      MakeMakefile.rm_f tmplog
    end
  end
end