[#50466] [ruby-trunk - Bug #7492][Open] Segmentation fault at DL::TestDL#test_call_double on x64 Windows 8 — "phasis68 (Heesob Park)" <phasis@...>

23 messages 2012/12/02

[#50558] [ruby-trunk - Feature #7511][Open] short-circuiting logical implication operator — "rits (First Last)" <redmine@...>

12 messages 2012/12/04

[#50575] [ruby-trunk - Feature #7517][Open] Fixnum::MIN,MAX — "matz (Yukihiro Matsumoto)" <matz@...>

20 messages 2012/12/05

[#50755] Becoming a committer — Charlie Somerville <charlie@...>

Hi ruby-core,

21 messages 2012/12/11
[#50759] Re: Becoming a committer — Yukihiro Matsumoto <matz@...> 2012/12/11

Hi,

[#50784] Re: Becoming a committer — Charles Oliver Nutter <headius@...> 2012/12/11

It's really this easy? If so, I'll send over my public key today :)

[#50795] Re: Becoming a committer — Yukihiro Matsumoto <matz@...> 2012/12/11

Hi,

[#50806] [ruby-trunk - Feature #7548][Open] Load and Require Callbacks — "trans (Thomas Sawyer)" <transfire@...>

12 messages 2012/12/12

[#50810] [ruby-trunk - Feature #7549][Open] A Ruby Design Process — "brixen (Brian Ford)" <brixen@...>

34 messages 2012/12/12

[#50867] [ruby-trunk - Bug #7556][Assigned] test error on refinement — "usa (Usaku NAKAMURA)" <usa@...>

14 messages 2012/12/13

[#50900] [ruby-trunk - Bug #7564][Open] r38175 introduces incompatibility — "tenderlovemaking (Aaron Patterson)" <aaron@...>

14 messages 2012/12/14

[#50951] [ruby-trunk - Bug #7584][Open] Ruby hangs when shutting down an ssl connection in gc finalization — "bpot (Bob Potter)" <bobby.potter@...>

12 messages 2012/12/17

[#51076] [ruby-trunk - Feature #7604][Open] Make === comparison operator ability to delegate comparison to an argument — "prijutme4ty (Ilya Vorontsov)" <prijutme4ty@...>

12 messages 2012/12/22

[#51170] [ruby-trunk - Bug #7629][Open] Segmentation fault — "atd (Antonio Tapiador)" <atapiador@...>

13 messages 2012/12/28

[ruby-core:51043] [ruby-trunk - Bug #7303][Assigned] Logger fails on log rotation in Windows (log shifting failed. Permission denied)

From: "usa (Usaku NAKAMURA)" <usa@...>
Date: 2012-12-21 13:21:35 UTC
List: ruby-core #51043
Issue #7303 has been updated by usa (Usaku NAKAMURA).

Status changed from Open to Assigned


----------------------------------------
Bug #7303: Logger fails on log rotation in Windows (log shifting failed. Permission denied)
https://bugs.ruby-lang.org/issues/7303#change-34949

Author: pink-ink (Herman Munster)
Status: Assigned
Priority: Normal
Assignee: nahi (Hiroshi Nakamura)
Category: lib
Target version: 
ruby -v: ruby 1.9.3p0 (2011-10-30) [i386-mingw32]


I have the problem that the logger fails in rotating the log file (daily) with Ruby 1.9.3 in Windows 7.

The cause is, that the log file is open and shall be renamed.
This results in an error "log shifting failed. Permission denied".

Log rotating will work, if the log file is copied to the age_file and then the logfile is cleaned by using logdev.truncate(0).

My changes to logger.rb are (remove 3 lines, add 2 lines):

    def shift_log_period(period_end)
      postfix = period_end.strftime("%Y%m%d")# YYYYMMDD
      age_file = "#{@filename}.#{postfix}"
      if FileTest.exist?(age_file)
        # try to avoid filename crash caused by Timestamp change.
        idx = 0
        # .99 can be overridden; avoid too much file search with 'loop do'
        while idx < 100
          idx += 1
          age_file = "#{@filename}.#{postfix}.#{idx}"
          break unless FileTest.exist?(age_file)
        end
      end
-     @dev.close rescue nil
-     File.rename("#{@filename}", age_file)
-     @dev = create_logfile(@filename)
+     FileUtils.cp(@filename, age_file)
+     reset_logfile(@dev)  # see below for this new method
      return true

I've added a new method to clean the open logfile and add a log header:
    def reset_logfile(logdev)
      logdev.truncate( 0 )
      logdev.sync = true
      add_log_header(logdev)
    end

The change above (copy/clean instead of rename) should also be
applied to the method "shift_log_age", same problem here.

I don't know how to bring this code into standard ruby sources.
Please somebody change the code, so the bug will be fixed.

(I found this bug also described in the old RubyForge archive: http://rubyforge.org/tracker/?group_id=426&atid=1698&func=detail&aid=19709)


-- 
http://bugs.ruby-lang.org/

In This Thread