Граф коммитов

69 Коммитов

Автор SHA1 Сообщение Дата
tenderlove 655b3da03c Fixes the File::CREAT logger documentation
Co-Authored-By: Matias Korhonen <matias@kiskolabs.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-25 18:04:16 +00:00
normal f729089f44 logger: use safe navigation operator
Saves a few hundred bytes of bytecode in a frequently loaded module.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-18 00:52:01 +00:00
sonots 7176eb2df9 * lib/logger.rb (Logger::LogDevice#open_logfile, #create_logfile):
Logger should be able to open only files [Bug #14212]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-21 05:07:43 +00:00
sonots 93fe0ff2f1 logger.rb: Fix handling progname
Because progname was memoized with ||= a logger call that involved
outputting false would be nil. Example code:

  logger = Logger.new(STDOUT)
  logger.info(false)  # => nil

Perform an explicit nil check instead of ||= so that false will be output.

patched by Gavin Miller <gavingmiller@gmail.com> [Fix GH-1667]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-20 16:47:26 +00:00
normal 7142f5b595 logger: remove redundant opt_str_freeze use
Strings in "when" statements are allocation-free, so there's
never any reason to uglify the code to use opt_str_freeze over
the normal putobject instructions, here.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-24 07:29:33 +00:00
nobu f6e77b9d35 logger.rb: fix next rotate time
* lib/logger.rb (Logger::LogDevice#initialize): calculate next
  rotate time based on the mtime of the last existing file.
  [ruby-dev:49881] [Bug #12948]

Author: Tsukasa Oishi <tsukasa.oishi@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-16 06:59:42 +00:00
hsbt 990b23bbbc * lib/logger.rb: Improve Logger.new option documentation.
[Feature #12803][ruby-core:77467]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-14 09:01:01 +00:00
nobu 8fc170a34e logger: fix monthly log rotate with DST
* lib/logger.rb (Logger::Period#next_rotate_time): fix monthly log
  rotate when DST is applied during a month of 31 days.
  [Fix GH-1458]

With DST the month of october can actually last more than 31 days.
It can last 31 days plus 1 hour. So during october, `t` used to be
equal to "2016-10-31 23:00:00" instead of "2016-11-01 00:00:00".
This was then normalized to "2016-10-01 00:00:00" which lead every
single line of log during october to rotate the log file.
This fix ensure that next_rotate_time(now, 'monthly') always return
the first day of next month in every situation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-08 00:06:57 +00:00
kazu 81ac73c04d [DOC] Fix default value of shift_age [ci skip]
`LogDevice#initialize` treats shift_age: nil as 7, but
Logger#initialize has the default value of shift_age as 0.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-03 12:21:14 +00:00
sonots 2c6f15b1ad * lib/logger.rb: Add shift_period_suffix option [Fix GH-10772]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-18 15:07:31 +00:00
sonots a040953386 Allow specifying logger parameters in constructor
* lib/logger.rb: Allow specifying logger prameters such as level,
  progname, datetime_format, formatter in constructor [Bug #12224]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-18 10:45:40 +00:00
nobu 84d818678f Logger: simple refactoring
* lib/logger.rb (Logger#level=): remove unnecessary local
  variable.
* lib/logger.rb (Logger#initialize, Logger#reopen): [DOC] mention
  the default values.  cherrypicked from [GH-1319].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-06 01:56:16 +00:00
nobu a435fae7bd logger.rb: kwd args
* lib/logger.rb (Logger::LogDevice#initialize): define using
  keyword arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-08 15:07:05 +00:00
sonots 460e9d8d83 * lib/logger.rb: Remove block from Logger.add as it's not needed
patch provided by Daniel Lobato Garcí [fix GH-1240] [Bug #12054]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-09 07:41:51 +00:00
naruse 3e92b635fb Add frozen_string_literal: false for all files
When you change this to true, you may need to add more tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16 05:07:31 +00:00
sonots 8594cab140 * lib/logger.rb: expose logger mutex
[fix GH-541] Patch by @arthurnn

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-20 14:16:56 +00:00
sonots 398abe4c51 * lib/logger.rb: support symbol and string log level setting
[fix GH-1101]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-17 14:15:25 +00:00
sonots f952570bdd lib/logger.rb: Add Logger#reopen
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-17 13:58:57 +00:00
nobu 6df21cb469 logger.rb: end of week should be Saturday
* lib/logger.rb (Logger::Period#previous_period_end): as weekly
  rotation shifts the log file on Sundays, the end date of the
  previous period should be Saturdays.  fix r45072.
  [ruby-dev:49314] [Bug #11622]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-27 07:18:14 +00:00
nobu e8c00b7027 logger.rb: fix weekly rotation
* lib/logger.rb (Logger::Period#next_rotate_time): get rid of
  adding to mday not to exceed the days of the month.
  [ruby-core:71185] [Bug #11620]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-27 03:00:38 +00:00
nobu 6160e4b9f4 logger.rb: exact matching
* lib/logger.rb ({next,previous}_rotate_time): dispatch by exact
  matching shift_age instead of regexp matching.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-26 14:51:39 +00:00
nobu aeb88f01eb logger.rb: freeze constants
* lib/logger.rb: freeze constant strings and array.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-26 14:51:04 +00:00
nobu 2bded596ec logger.rb: simplify
* lib/logger.rb (format_datetime): simplify and freeze the default
  format so that it can be shared.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47272 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-25 04:03:33 +00:00
nobu 51560a8737 lib/logger.rb: use %N
* lib/logger.rb (format_datetime): use "%6N" to show microsecond.
  [Fix GH-704]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-25 03:56:53 +00:00
hsbt 931d2fd5d8 * logger.rb: removed unmaintain code.
[Feature #9860][ruby-core:62724]
* test/logger/test_application.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-02 01:41:02 +00:00
hsbt 4f7449beba * lib/gserver.rb: remove redundant use of to_s in interpolation.
* lib/logger.rb: ditto.
* lib/optparse.rb: ditto.
* lib/rbconfig/obsolete.rb: ditto.
* lib/resolv.rb: ditto.
* lib/webrick/httpresponse.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-24 08:48:46 +00:00
hsbt cc0ca767f5 * lib/logger.rb: refactored to include Logger::Period.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-24 23:54:17 +00:00
nobu be5de49090 logger.rb: DST
* lib/logger.rb (next_rotate_time, previous_period_end): consider
  DST change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-21 07:45:55 +00:00
nobu 82d495134c logger.rb: fix midnight log rotation miss
* lib/logger.rb (Logger::LogDevice#check_shift_log): compare the
  current time with the time for the next rotation to fix rotation
  miss when date changed between the comparison and log writing.
  based on the patch by megayu <yuhg2310 AT gmail.com>.
  [Fixes GH-539]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-21 07:11:03 +00:00
hsbt 98e82f3506 * lib/logger.rb: [DOC] Fix arg name for Logger.new by @ryotarai [ci skip] [fix GH-531]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-11 00:10:13 +00:00
nobu 95ed081663 logger.rb: fix extra log ratation
* lib/logger.rb (lock_shift_log): no need to rotate the log file
  if it has been rotated by another process.  based on the patch
  by no6v (Nobuhiro IMAI) in [ruby-core:58620].  [Bug #9133]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-14 05:43:01 +00:00
nobu 3c8072937c logger.rb: fix r43511 for Windows
* lib/logger.rb (Logger::LogDevice::LogDeviceMutex#lock_shift_log):
  open file can't be removed or renamed on Windows.  [ruby-dev:47790]
  [Bug #9046]
* test/logger/test_logger.rb (TestLogDevice#run_children): don't use
  fork.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-02 06:15:02 +00:00
naruse 0749adc54c * lib/logger.rb: Inter-process locking for log rotation
Current implementation fails log rotation on multi process env.
  by sonots <sonots@gmail.com>
  https://github.com/ruby/ruby/pull/428 fix GH-428 [Bug #9046]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-01 22:14:42 +00:00
zzak 30ce930f37 * lib/logger.rb: Use :call-seq: for method signature rdoc
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10 14:30:12 +00:00
zzak fef0a7deaf * lib/logger.rb (#add): Remove incorrect rdoc for return value
[Bug #8567] Reported by Tim Pease.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-10 14:25:06 +00:00
eregon 3786bd6096 * lib/logger.rb (Logger::Application): show namespace in documentation
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-20 10:35:01 +00:00
drbrain c4827de949 * lib/logger.rb: Updated example in Logger comment to match other
examples and fixed a bug.  Patch by Marcus Stollsteimer.
  [Bug #6759]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-20 23:41:51 +00:00
drbrain fe6aa0e16a * lib/logger.rb: Updated typos and output to match modern Logger
output.  Patch by Marcus Stollsteimer.  [Bug #6738]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-18 00:27:04 +00:00
nobu d371e3583e * lib: revert r31635-r31638 and untabify with expand(1).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-19 00:07:25 +00:00
drbrain 7bbf2f3085 * lib: Convert tabs to spaces for ruby files per
http://redmine.ruby-lang.org/projects/ruby/wiki/DeveloperHowto#coding-style
	  Patch by Steve Klabnik [Ruby 1.9 - Bug #4730]
	  Patch by Jason Dew [Ruby 1.9 - Feature #4718]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-18 21:19:18 +00:00
nobu 7dd49ed5a7 * lib: remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-18 14:09:38 +00:00
drbrain 532f1485d3 * lib/logger.rb: Improve documentation. Patch by David Copeland.
[Ruby 1.9 - Bug #4706]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-16 21:43:20 +00:00
nagachika 58355ea52a * lib/logger.rb: format comments to keep 80 columns in a line.
* lib/uri/common.rb: ditto.
  * lib/uri/ftp.rb: ditto.
  * lib/uri/ldap.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-13 12:54:57 +00:00
drbrain f154226900 * lib/logger.rb (class Logger): Document Logger#datetime_format.
Patch by Sergio Gil Pérez de la Manga.  [Ruby 1.9 - Bug #4678]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-12 20:45:45 +00:00
nagachika 1111afbe5a * lib/csv.rb: fix a typo.
* lib/logger.rb: ditto
  * lib/rss.rb: ditto
  * lib/webrick/httpauth/authenticator.rb: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-11 10:22:16 +00:00
nahi 9ffaa7e96b * lib/logger.rb: added RDoc document for logging message escape
by Hal Brodigan. See #3869


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-18 06:11:41 +00:00
marcandre 70510d026f * lib/csv.rb: Fix unused variable warnings.
Patch by Run Paint [ruby-core:30991]

* lib/date.rb: ditto

* lib/debug.rb: ditto

* lib/drb/drb.rb: ditto

* lib/drb/invokemethod.rb: ditto

* lib/irb/ruby-lex.rb: ditto

* lib/irb/slex.rb: ditto

* lib/logger.rb: ditto

* lib/pathname.rb: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-07-11 16:59:10 +00:00
nahi 8906bf2c1b * lib/logger.rb: imported upstream version (logger/1.2.7) see #2238.
* do not raise an exception even if log writing failed.
          * do not raise ShiftingError if an aged file already exists.
            (no ShiftingError will be raised from 1.2.7, just warn() instead)
        * test/logger/test_logger.rb: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-20 15:08:38 +00:00
matz 29927214d4 * lib/logger.rb (Logger): should handle the case that cvs/svn do
not expand $Id keyword.  [ruby-core:19991]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-19 22:35:40 +00:00
nobu fd346f769b * lib/logger.rb (ProgName): fixed typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-18 07:32:44 +00:00