clogger RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [ANN] clogger 2.4.0 - configurable request logging for Rack
@ 2022-06-16 16:59  4% Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2022-06-16 16:59 UTC (permalink / raw)
  To: clogger-public, ruby-talk

Clogger is Rack middleware for logging HTTP requests.  The log format
is customizable so you can specify exactly which fields to log.

Changes:

    Only 2 code changes, neither of which is really relevant for 99% of
    users using the C extension and strict HTTP parsers.

          escape env['REQUEST_METHOD'] for non-strict HTTP servers
          pure: fix time.rb incompatibility in Ruby 3.1+
          doc: drop git:// URLs, use shorter domain for IMAP links

* public mailbox: https://YHBT.net/clogger-public/
* mailto:clogger-public@YHBT.net (no HTML, don't top post)
* homepage: https://YHBT.net/clogger/
* git clone https://YHBT.net/clogger.git
* torsocks git clone http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/clogger.git
* Atom feed: https://YHBT.net/clogger/NEWS.atom.xml

^ permalink raw reply	[relevance 4%]

* [PATCH] pure: fix time.rb incompatibility in Ruby 3.1+
@ 2022-06-16 16:13  7% Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2022-06-16 16:13 UTC (permalink / raw)
  To: clogger-public

The time.rb distributed with Ruby 3.1+ no longer has the
RFC2822_MONTH_NAME constant, as Time#strftime in Ruby is
locale-independent (unlike strftime(3) in C).

This doesn't affect the default C extension, it only affects the
pure Ruby code used for Ruby implementations without C extension
support.

cf. ruby.git commit 5307fab6619e26e05d791d68c35ceef2e923e8d5
---
 lib/clogger/pure.rb | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/lib/clogger/pure.rb b/lib/clogger/pure.rb
index 7f82992..4b38e90 100644
--- a/lib/clogger/pure.rb
+++ b/lib/clogger/pure.rb
@@ -133,17 +133,10 @@ private
     when :time_iso8601
       Time.now.iso8601
     when :time_local
-      t = Time.now
-      off = t.utc_offset
-      sign = off < 0 ? '-' : '+'
-      sprintf("%02d/%s/%d:%02d:%02d:%02d #{sign}%02d%02d",
-              t.mday, Time::RFC2822_MONTH_NAME[t.mon - 1],
-              t.year, t.hour, t.min, t.sec, *(off.abs / 60).divmod(60))
+      # %b in Ruby is locale-independent, unlike strftime(3) in C
+      Time.now.strftime('%d/%b/%Y:%H:%M:%S %z')
     when :time_utc
-      t = Time.now.utc
-      sprintf("%02d/%s/%d:%02d:%02d:%02d +0000",
-              t.mday, Time::RFC2822_MONTH_NAME[t.mon - 1],
-              t.year, t.hour, t.min, t.sec)
+      Time.now.utc.strftime('%d/%b/%Y:%H:%M:%S %z')
     else
       raise "EDOOFUS #{special_nr}"
     end

^ permalink raw reply related	[relevance 7%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2022-06-16 16:13  7% [PATCH] pure: fix time.rb incompatibility in Ruby 3.1+ Eric Wong
2022-06-16 16:59  4% [ANN] clogger 2.4.0 - configurable request logging for Rack Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/clogger.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).