Module: 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



296
297
298
# File 'lib/mkmf.rb', line 296

def quiet
  @quiet
end

Class Method Details

.log_closeObject



270
271
272
273
274
275
276
# File 'lib/mkmf.rb', line 270

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

.log_openObject



245
246
247
248
# File 'lib/mkmf.rb', line 245

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

.logfile(file) ⇒ Object



265
266
267
268
# File 'lib/mkmf.rb', line 265

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

.message(*s) ⇒ Object



260
261
262
263
# File 'lib/mkmf.rb', line 260

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

.openObject



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

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

.postponeObject



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/mkmf.rb', line 278

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
      rm_f tmplog
    end
  end
end