Sha256: 6e6a1cea72a24e098fbca7d3683d992ad9206218badc9d7f5c0dc20e9b20750a
Contents?: true
Size: 552 Bytes
Versions: 2
Compression:
Stored size: 552 Bytes
Contents
class Ginst::Logger def initialize(file) @filename = file @file = File.open(file,'a') @file.sync = true ObjectSpace.define_finalizer(self) do puts self.class.to_s puts 'Cerrando log file' @file.close end end def log(msg,acaller = nil) acaller ||= caller msg = format_msg(msg,acaller) @file.write(msg) msg end def format_msg(msg, caller) call = File.basename(caller.first).split(":")[0..1].join(":") "[%s %s] %s\n" % [Time.now.to_s, call, msg] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ginst-2009.11.24 | lib/ginst/logger.rb |
ginst-2009.11.23 | lib/ginst/logger.rb |