Module: Egalite::AccessLogger
- Defined in:
- lib/egalite.rb
Constant Summary collapse
- @@io =
nil
- @@time =
nil
- @@lock =
Monitor.new
Class Method Summary collapse
Class Method Details
._open ⇒ Object
38 39 40 41 42 43 |
# File 'lib/egalite.rb', line 38 def _open @@dir = dir @@time = Time.now fn = sprintf("egaliteaccess-%04d-%02d-%02d-p%d.log", @@time.year, @@time.month, @@time.mday, Process.pid) @@io = open(File.join(dir,fn), "a") end |
.io=(io) ⇒ Object
35 36 37 |
# File 'lib/egalite.rb', line 35 def io=(io) @@io=io end |
.open(dir) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/egalite.rb', line 44 def open(dir) @@dir = dir yield ensure @@io.close if @@io end |
.write(line) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/egalite.rb', line 50 def write(line) return nil unless @@io @@lock.synchronize { if @@time and (@@time.mday != Time.now.mday) ## log rotation @@io.close _open end @@io.puts(line) } end |