Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118865 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 53928 invoked from network); 21 Oct 2022 07:48:09 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 Oct 2022 07:48:09 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BAF2A180044 for ; Fri, 21 Oct 2022 00:48:08 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 21 Oct 2022 00:48:08 -0700 (PDT) Received: by mail-ed1-f47.google.com with SMTP id a67so3026797edf.12 for ; Fri, 21 Oct 2022 00:48:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=team.bumble.com; s=google; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=nF8+5SKZbcsrknUj9GW1TA8TH35pYJ9D/Czyhz1PchM=; b=5/x3yu3juTBnJ+uB+i5u1c0WIhFFtdPkI0aykD128Voqi7o8FlAZLdg1Ykqkprxgle C+k/2+F0ZMTCKG6b+IgdDp9RpqodqhVsO0DYy0peEmCL+dBuxTIR6ARU0RPOpLwqUU6X HQIrha4W9wcD7JbA5bAbCIDPIKtpBchAOkVE4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=nF8+5SKZbcsrknUj9GW1TA8TH35pYJ9D/Czyhz1PchM=; b=JSaMgO8LoxgSW79u1/nV1VlKy8qfSY5OFHBqE89jYcq8c6RmLakervosIz/8wQlVfN 1ZaU1vklGsEVmd6noqNvJKEJomLyr4Wfs+vv6N4O9lrI3bSiXs7REvXqbKQ3isA9clXk Jv0jb3XJViMKO+DTLv/1fUn3QsNmN4IiySONsKWcF6nbUZ6jM4qTlNqKXki/ACLs9MxZ hKehca5JqDI9NwiJSyaNbIlztWoULjviR0bxoHEW060Pj+U2yNKHmqQmPTUWmRqCot7P A5ALrR3L6dVweeRdC6dfjGm058Mad5m4bi+pOjVEZJrHCS/re3XfBKp6qKQQOujAc1qU +E2A== X-Gm-Message-State: ACrzQf0n/HoMYpQB8uxUUKSBf/ajez7HRtLwp88xoD5S0uOFy35QFO2x ApHXGk9q3PSnDmp6klrGIWhtHsSLQYs2QC89sPQzaU4nn3klag== X-Google-Smtp-Source: AMsMyM50vjNlG03CXQlTW+0YD3oRq8Z427JKyuGbDEPLgXUKbZTHvYPsPoPIN3RqXB4cbkd0VUplnZ9IezkF8bVkE5I= X-Received: by 2002:aa7:ce09:0:b0:461:5406:20e4 with SMTP id d9-20020aa7ce09000000b00461540620e4mr491727edv.5.1666338486521; Fri, 21 Oct 2022 00:48:06 -0700 (PDT) MIME-Version: 1.0 Reply-To: Mikhail Galanin Date: Fri, 21 Oct 2022 08:47:30 +0100 Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Subject: Microseconds to error log From: internals@lists.php.net ("Mikhail Galanin via internals") Description Hi there, I started this thread on GitHub but Christoph (cmb69) suggested this is the better place to discuss such a thing. (initial post: https://github.com/php/php-src/issues/9745) Basically, we have quite a high-loaded environment and we really want to see timestamps containing milli-/microseconds in our logs. It is easy to do for our custom logger but error messages from the PHP itself narrowed down to seconds (I'm talking about method php_log_err_with_severity() Link: https://github.com/php/php-src/blob/master/main/main.c#L799:~:text=php_log_err_with_severity In our repository, we have a hacky patch that adds microsecs in this log as well. Unfortunately, such a solution is not really a good approach to looking into the future. I wanted to adopt our patch to share it with the community and potentially merge it into upstream but stumbled upon the fact that it isn't really straightforward to format a date/time with microseconds using the standard API available for an extension. Basically, I found a couple of options: (1) We can instantiate a DateTime object and call DateTime::format(). It looks working but it makes the logging function way more complicated and potentially heavy (2) date_format works directly with timelib_time and can properly handle microsecs but it is hidden inside ext/date/php_date.c, Not really sure if it's a good idea to make it public (3) In theory, it is possible to add one more parameter to php_format_date but it'll break all the existing code. The change of signature doesn't look like a good option. However, we might be able to introduce another function if we want to encapsulate work with timelib_time within the ext/date. (4) Derrek Rethans suggested introducing a new function (e.g. php_format_date_ex) that takes care of usecs (see the thread on Github) Looking into the future, probably we would like to have this format configurable, if so it looks easy to do but still I can't see an easy way to handle the microseconds issue. Could you please help me to find the right way and share your thoughts about this topic (maybe there are strong objections against such a change)?