From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.4 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from mail-io0-x240.google.com (mail-io0-x240.google.com [IPv6:2607:f8b0:4001:c06::240]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 7A53F20285 for ; Thu, 29 Jun 2017 02:30:58 +0000 (UTC) Received: by mail-io0-x240.google.com with SMTP id j200sf6984097ioe.0 for ; Wed, 28 Jun 2017 19:30:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1498703458; cv=pass; d=google.com; s=arc-20160816; b=MI3hbAlepaXFzaFlIHKyqTW+knAGipX+llriMKcA2kgnPerYm2yv6RiHirId2AAd52 XYd078b+HKhiAAXGfRKAwyfaaxd8s4weJJuqNp61zcRzHBpinzyw885oGta793kuwD8o jHOmyfFkrXmOXQgIQB63lpy+hV52USysCFyeY0s/ioTXdzCyv4ZwxkGGzlolU4XGZb0h iyQDs+TD63/3aZ+RCV5QR1wtcF2iTH0OrVw+dMi1dBxY7PLHa9JSPqwUfFHsW4IbnsyO kNI7ZfalLku1O9MN0Lcnti9ihM+ePF3pZG5wkCNMGRpcaPvkBPw9PWSPfSw+VOSpMXEs vCPA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:content-disposition :mime-version:message-id:subject:to:from:date :arc-authentication-results:arc-message-signature:sender :dkim-signature:arc-authentication-results; bh=h9FDMJWbKNsFhW4sgVBnW04gahdLcFXEM2M9TL5zR48=; b=eiSfRL/76+iy58HFWmr2gYm6ctoxFH9aszw3QLjokhRfJP+D1xC51pn7q5GUbzj6hE JKOtibgpPSEgm4LyTQj23HypjPkppBv8mO1dAh7NwijPjR3h73kWHXg8OrwKGhvigEh6 L6nPu7d5dv98ycjJLJh3sbhyvUjBErxUfZgzzFxSm1GqzGkirMOvzbLLK/ku0YUHeO+G aHmuRUsfswRiNjAZU4W2OFdagDNeGfDykCDAWLLF2B46o7HQyOOHtEfMQyyHEp6YYBzC n5WuK5MCBzkRRq7wv8yT9jk98U/EuVstLFqyD7aw80v5bIExPEnm4SL59h4G+ybbTSkS hU2g== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of e@80x24.org designates 64.71.152.64 as permitted sender) smtp.mailfrom=e@80x24.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:date:from:to:subject:message-id:mime-version :content-disposition:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=h9FDMJWbKNsFhW4sgVBnW04gahdLcFXEM2M9TL5zR48=; b=ntCCtscRdRBwjgIIDLKIfyiTII2Fx6COIaAil2fpSYi7LbSd4YvStlj0ZBK1F30jVP WEsRnsHohWahBJyZPHLK+agIp7yf95IUcUTyC3zA2jUbpSAwJwfHz0OlVt3vGGBx9bRY ChQT3eTD47ei3+3po1DpxJmdyKbZ1bwT/sf4zZqBSc0QHonoudefa8v1WSDCTBxvX2hr t0w9YiXh2CPvkJZwW5K4wCZSdNEz0UGE8gg96Umj9JDYAJM+88t4/bXcMfYg6Lbje1UZ XdBQDdWUS+9tQ/YxUX7a+DbcVA0AfSt8fGTd9VVDUA8woG3dYfTXXzl5QR++dIvkan3Z xO3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:date:from:to:subject:message-id :mime-version:content-disposition:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=h9FDMJWbKNsFhW4sgVBnW04gahdLcFXEM2M9TL5zR48=; b=Q9jJ6RIAm4e2zsOUQVpq3Vz526osNTbpO3J8DpJEulElmCiubT30hf3gGeFRViOAgg jN4qvCJi09OCHT/0OXfUY8bJdTucCi8eHNEuXHexVdXtnDdyieK8Jb2MFRbTiO0eGcjL BLMWwp+i75M/dZ9WoIKq5mluIu2Iaskmha/j7jRsnhrsC6dfBA7q6ntMpyFnQXEzbbHd CKi1frVq3pUU4EsBa7Gk3v11fDX8m0IgEGm11uLlXBjiGL1vziZwCjGpPHkMxesADhfW CY3sRY9m3l6rZpjLDwH1hxrM39ilP71cW1HJ08Fu7NM8Tm9iKt7GTgDynTeml0iCZkEE jT6g== Sender: rack-devel@googlegroups.com X-Gm-Message-State: AKS2vOyab10TVj6TejFGVH0HoiROs6NaQxMWvl9qnpkILVzjTxpUCki7 Z2tJrv0ehsntqA== X-Received: by 10.36.69.103 with SMTP id y100mr264926ita.0.1498703458027; Wed, 28 Jun 2017 19:30:58 -0700 (PDT) X-BeenThere: rack-devel@googlegroups.com Received: by 10.107.37.13 with SMTP id l13ls1789189iol.19.gmail; Wed, 28 Jun 2017 19:30:57 -0700 (PDT) X-Received: by 10.99.165.26 with SMTP id n26mr8892500pgf.9.1498703457498; Wed, 28 Jun 2017 19:30:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498703457; cv=none; d=google.com; s=arc-20160816; b=psvZvTOhEA5y6sn6RDmvm2lwe1wyv1H4CKGPAfUyv3i06Idk+xt6JK6aYUiRMfLhle SseYAuQbCM0y4D7nmDz9rb0bkuNZFQmoCd6pTcU40K3iCW9jjJb53LXr94ar3i+m1z1k PslwAVQlGUMTi5hxxCBoiLePt8QAYhPCWVZ/q9/0ph6r6ti5xQncLh5i/0oRfp1SIgBz /aB25IPrfVUT8J8WPlkT3wT4jEDQxPqBK4tEc5sYlH+pp1Y6/WrTWxyHrmyloIpy89WB cZ3P7c7WSVLXE6/K+au8SYKwztFHqt2hcZL9NnqoKA8uE7flNaU43RG/y2WCeXTxK1M7 KzvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:message-id:subject:to:from:date :arc-authentication-results; bh=7ujzT0UQT5D8KYgMw9+QaG3kxNEZ5kXoTy1KaOsq2AM=; b=Wz/ZdvU0vsAMzOGVaqiuiBKq99sf5uXQO1Rx+3M08beoze3p0Iu2OUyHzwffXx86Uw X2NHa5qc9rX2KfAPOeTg83rlHokSHt5GOUPkKqv448B0w2b5mDvTtmi6xn5KOdiQGiY1 tyOIsM8nVriTRxea6xUxIeFwtjyziCVnuo/az5hVpmrf99TcSMZyfTEocS3D7eiYv/me SZcyZzvKC95ga07FjvyUsKz8FqKkO84ArmsADvwFLpvQLcYNNKiKQqGo+SZZFoxWBOYg 4IgxpuWlx49eRaGX4FSEsgv4tyVARg0ZQvMkY4j60j7m9KcyWyyo4HrES/Ga5ni/kyAU rYrA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of e@80x24.org designates 64.71.152.64 as permitted sender) smtp.mailfrom=e@80x24.org Received: from dcvr.yhbt.net (dcvr.yhbt.net. [64.71.152.64]) by gmr-mx.google.com with ESMTPS id e12si853557pfd.8.2017.06.28.19.30.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2017 19:30:57 -0700 (PDT) Received-SPF: pass (google.com: domain of e@80x24.org designates 64.71.152.64 as permitted sender) client-ip=64.71.152.64; Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id ACECA20285; Thu, 29 Jun 2017 02:30:56 +0000 (UTC) Date: Thu, 29 Jun 2017 02:30:56 +0000 From: Eric Wong To: rack-devel@googlegroups.com Subject: [PATCH] common_logger: rely on monotonic clock Message-ID: <20170629023056.GA22961@untitled> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline X-Original-Sender: e@80x24.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of e@80x24.org designates 64.71.152.64 as permitted sender) smtp.mailfrom=e@80x24.org Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: X-Google-Group-Id: 486215384060 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , As with commit 2474e3a779a8d2b6 for Rack::Runtime, Time.now is inaccurate if system time changes, so do not rely on it if a monotonic clock is available. --- The following changes since commit 0362a54dba92626582d42f3343c209b7cdb7e713: Partially reverting 8a7a142d (2017-06-28 13:20:52 -0700) are available in the git repository at: git://80x24.org/rack logger-time for you to fetch changes up to 743f29d845b627b6083eaf6380ec6442f7427de7: common_logger: rely on monotonic clock (2017-06-29 02:25:00 +0000) ---------------------------------------------------------------- Eric Wong (1): common_logger: rely on monotonic clock lib/rack/common_logger.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/rack/common_logger.rb b/lib/rack/common_logger.rb index ae41043..7855f0c 100644 --- a/lib/rack/common_logger.rb +++ b/lib/rack/common_logger.rb @@ -29,7 +29,7 @@ module Rack end def call(env) - began_at = Time.now + began_at = Utils.clock_time status, header, body = @app.call(env) header = Utils::HeaderHash.new(header) body = BodyProxy.new(body) { log(env, status, header, began_at) } @@ -39,20 +39,19 @@ module Rack private def log(env, status, header, began_at) - now = Time.now length = extract_content_length(header) msg = FORMAT % [ env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"] || "-", env["REMOTE_USER"] || "-", - now.strftime("%d/%b/%Y:%H:%M:%S %z"), + Time.now.strftime("%d/%b/%Y:%H:%M:%S %z"), env[REQUEST_METHOD], env[PATH_INFO], env[QUERY_STRING].empty? ? "" : "?#{env[QUERY_STRING]}", env[HTTP_VERSION], status.to_s[0..3], length, - now - began_at ] + Utils.clock_time - began_at ] logger = @logger || env[RACK_ERRORS] # Standard library logger doesn't support write but it supports << which actually -- EW -- --- You received this message because you are subscribed to the Google Groups "Rack Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to rack-devel+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout.