Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122294 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 71744 invoked from network); 6 Feb 2024 14:56:19 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Feb 2024 14:56:19 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1707231431; bh=LQRQ7AXLJR9TLt4JCxhUeMvUMfI/6N6oenPaVGPoHUM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ar+p/d/6XjtNXo8qcDxOigqtrKvV+m4hABARQXGT5gho1Zv7nycrYHj7nCBztCyV6 ctAaUJJSTI/wIxo1P6B9ZDHuTQSZm2BUdi32iO6cRlyki4x5wkXIVh95OZ2pPuhzIt KRfSykWiHjn/Es3yfR2Ws9lvsxGorrw/fAJUWqB0XtCJbsa3cKISmi4dUbNCFvTr+X QZ62ajhpNWDlDi7gJTQKCYl+5BI5CMjeNniWMdRF/g0/pQNrLsw8dvGLBQaUCOfFea OEQilLiEeOL8Rn2WQCLhsGvNTSJpEMoqruBvUS4DjQM3EJ12zm7FkUXewyU8UugEVP hfXGV1LkUlJyg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DC13C180039 for ; Tue, 6 Feb 2024 06:57:10 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_FROM,FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 6 Feb 2024 06:57:10 -0800 (PST) Received: by mail-il1-f171.google.com with SMTP id e9e14a558f8ab-363c869d850so7212245ab.0 for ; Tue, 06 Feb 2024 06:56:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707231378; x=1707836178; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=LQRQ7AXLJR9TLt4JCxhUeMvUMfI/6N6oenPaVGPoHUM=; b=HDCHvva2TSFtyyZz5Fh1r2QN8yTl/q4CdKxrBQTt4N0xgQ03ojAkuFwvV7651EPZSc jE/KLBJpbputIrl1Fgq4czU25UR6f/s3hUmpwQMAz7iiKNnSTxwgqm1LAniutDTbNxlr GQJO4KO4iAWk/O1foAtSI4lR8zZ0ZIQMDaYTf0J3UTl7v0Ml4EWxyWklwH6DkntJQVnD 0MNZO1dA6QK8/s92zwjc8SLYZHTFMKMRS6ron1ngu8GMxSN49g3fz2ui9/LZqB096q4J 8xxbt5plGtKBAuk/EBogPiAOgOs2tMFIhuXxd5EK+MgzyeR8rgG4TToXw5RL8wqFzZvk 4zaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707231378; x=1707836178; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LQRQ7AXLJR9TLt4JCxhUeMvUMfI/6N6oenPaVGPoHUM=; b=f9u0FwtW7cfEOagiZK3NyfTP1vaZBOcxZ53gC6hHLGwqE5usHEPQ/6zoqS+N2cbZGB n4+os+4YZM80y7PCyfib3EasSo8clMV7d2z9JI415ccbMJt1E52Gp8GV0pjXJBA4+Bz0 RGeI+lF8KLjyPOn+TqQCoqsj3491FYJC57yokCAhPvW82cR5+yfjQBd0Vto0YTHi6Z6s 0hE2ds5qbpUiVCNhID6+i8unFPCkSfnBMcIUhhm6e8Ov830gZ1zitct6fHAYUWkX7Jp3 qcGXGIJHo4/cZ2ElhVhGVYvW9SjG+r+DLuMr1QRtq/pOaxL6WWlpgnXVt4bg95w3AdIh nN/g== X-Gm-Message-State: AOJu0Yyo4KlZ2TAkgd6W3jw30XQidF02/sUwvxTbC2zBva4E4Q9ymhtO WYkFpJPGFNYY6aheXOlGCTJWTtMckQ/CXXG477qwZHgk0M/IdAZn+XkaCt0G3WNWG8u9EkoVF7C qMI3lfkmpUmwepZ7fUrU8r8t5U6yvr4SHf2s= X-Google-Smtp-Source: AGHT+IFN3PK/BVyXGm7TePieg06nWQfez63Mr+yA7goi6enCg9yDksq36mJcwJXmSfaUmd/zQLkuU5Lij2uboMkGb2o= X-Received: by 2002:a05:6e02:963:b0:363:a858:3139 with SMTP id q3-20020a056e02096300b00363a8583139mr2099744ilt.17.1707231377500; Tue, 06 Feb 2024 06:56:17 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 6 Feb 2024 16:55:41 +0200 Message-ID: To: =?UTF-8?B?0JPRgNC40LPQvtGA0LjQuSBTZW5pb3IgUEhQIC8g0KDQsNC30YDQsNCx0L7RgtGH0LjQuiBXZWI=?= <6562680@gmail.com> Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000ce302f0610b7c75a" Subject: Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301 From: arvids.godjuks@gmail.com (Arvids Godjuks) --000000000000ce302f0610b7c75a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 6 Feb 2024 at 16:39, Arvids Godjuks wrote: > > > On Tue, 6 Feb 2024 at 15:58, =D0=93=D1=80=D0=B8=D0=B3=D0=BE=D1=80=D0=B8= =D0=B9 Senior PHP / =D0=A0=D0=B0=D0=B7=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=87= =D0=B8=D0=BA Web < > 6562680@gmail.com> wrote: > >> Hello, please discuss about error collecting implementation in next PHP >> releases >> >> Exceptions have common differences that restrict using them to collect >> errors >> 1. Timeloss (trace collection) on call new() on any class that implement= s >> \Throwable >> 2. To collect errors and return it to the upper level you have to change >> the return signature, so most of the time rewrite the full tree and chan= ge >> all signatures, that's inapplicable and causes more refactor time withou= t >> any benefits >> 3. Exceptions will break code, so you need to catch them as much closely >> as >> possible to place you throw it (additional refactoring) >> >> What I want from this feature: >> - while I am writing the api, I need not only "log" the errors, but be >> able >> to send all script errors to json output, including warnings, errors, an= d >> deep nested. It will reduce the time of debugging, otherwise i have to >> download log files from server or configure external system like sentry >> that collects all errors by groups/chains >> >> Suggested solution: >> - add non-breakable interface and language construct `raise` to "throw" >> error without collecting trace >> - that error could be any scalar or object, or you can implement new >> interface for them, keeping that is nested and taggable array >> - this `raise` could be catched same way as \Throwable allowing log it >> anywhere you need or re-`raise` again >> - `raise` statement won't start to collapse/break code, so it could be >> skipped without affecting application >> >> Current solution: >> a) 2 classes - ErrorBag/ErrorBagStack. >> >> b) native functions like _error()/_warning() that stores errors to the >> current ErrorBag if it exists. >> >> c) ErrorBag exists only if you initialize it: >> - from the upper level (you need to collect) >> - directly inside a function (you need to decide return/continue dependi= ng >> on its emptiness) >> - otherwise _error()/_warning() does nothing >> >> d) once you "catch" results of _error()/_warning() you often need it to >> merge the result to the current errorbag, mark it with a nesting group o= r >> with the tag. Nesting group is required once you debug code (you will se= e >> the log), tags will needed once you want to copy results from one bag to >> another (closest example - reduce queue with unique function, do action, >> then work with initial data) >> >> e) useful feature is merge_as_warning($errorBag) - to prevent the curren= t >> error bag to return `true` on call ->hasErrors(). Errors are related to >> low >> level function, and possibly you already do actions that allow you just >> store them. >> >> f) searching inside the error bag by nesting sequence, or by tag, or by >> error type. Error type helps the same as try/catch, tag helps if you wan= t >> to save errors to several destinations without memory losses, and nestin= g >> will help most of the time in debugging. >> >> Thanks for your attention. >> >> -- >> +375 (29) 676-48-68 <+375296764868> / Mobile - =D0=BF=D1=80=D0=B5=D0=B4= =D0=BF=D0=BE=D1=87=D0=B8=D1=82=D0=B0=D0=B5=D0=BC=D1=8B=D0=B9 =D1=81=D0=BF= =D0=BE=D1=81=D0=BE=D0=B1 =D1=81=D0=B2=D1=8F=D0=B7=D0=B8 >> https://t.me/gzhegow / https://t.me/%2B375296764868 / Telegram >> 6562680@gmail.com >> > > Hello, > > This is an application design-level issue, not a language issue. > All you need to do is implement a collector on the logger you use that > will store the info you want and let you ask for that info just before yo= u > push data into the JSON encoder you use from that logger collector. It's = as > simple as that, you don't even need to change your existing code if it > already logs the information. > > -- > > Arv=C4=ABds Godjuks > +371 26 851 664 > arvids.godjuks@gmail.com > Telegram: @psihius https://t.me/psihius > Sending me multiple emails in private with rants is not a behaviour that's encouraged on this list. Please read the https://wiki.php.net/email_etiquette_for_people_new_to_php_internals --=20 Arv=C4=ABds Godjuks +371 26 851 664 arvids.godjuks@gmail.com Telegram: @psihius https://t.me/psihius --000000000000ce302f0610b7c75a--