From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.1 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 4337F1F954 for ; Fri, 17 Aug 2018 14:41:25 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id BD490120A41; Fri, 17 Aug 2018 23:41:21 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 7088B120A3C for ; Fri, 17 Aug 2018 23:41:18 +0900 (JST) Received: by filter0049p3las1.sendgrid.net with SMTP id filter0049p3las1-18774-5B76DE8A-C 2018-08-17 14:41:14.223069099 +0000 UTC m=+247.979786188 Received: from herokuapp.com (ec2-54-147-10-211.compute-1.amazonaws.com [54.147.10.211]) by ismtpd0021p1iad2.sendgrid.net (SG) with ESMTP id b9hZVXi-Ttyu96DmmNTWcw Fri, 17 Aug 2018 14:41:14.065 +0000 (UTC) Date: Fri, 17 Aug 2018 14:41:15 +0000 (UTC) From: mame@ruby-lang.org To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 63899 X-Redmine-Project: common-ruby X-Redmine-Issue-Id: 8661 X-Redmine-Issue-Author: gary4gar X-Redmine-Issue-Assignee: matz X-Redmine-Sender: mame X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS4LYqRUHbdSmZI93mPNeHP+nXoX30faXKBeNV rVYC/seFJllzGxygHrK51eJdD5knp3+yYrisOawE4v1v+/kQ38igtAI8H5DGDpLwuIKR5EA+RfN6RW IVhxtAYzKAZ85SMrTajTDkuFLEk3yjYFq8t62Vqsr9IeiZ1LnQZKvECoTw== X-ML-Name: ruby-core X-Mail-Count: 88515 Subject: [ruby-core:88515] [CommonRuby Feature#8661] Add option to print backstrace in reverse order(stack frames first & error last) X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #8661 has been updated by mame (Yusuke Endoh). Over one year has passed since the backtrace order was reversed. But I'm not still used to the new order. I agree with Samuel's points. In addition, the old order was more useful because it shows the last debug output and the exception message in one place. ``` $ ruby24 test.rb ... ... "debug print" "debug print" "the last debug print" test.rb:X:in 'buggy_func': exception message from test.rb:X:in `foo' from test.rb:X:in `bar' ... ... ``` In the above output, `"the last debug output"` and `test.rb:X:in 'buggy_func': exception message` are placed in one place. It is easy to understand the situation and to start debugging. However, the current behavior separates the two. This is very frastrating. ``` $ ruby25 test.rb ... ... "debug print" "debug print" "the last debug print" ... ... from test.rb:X:in `bar' from test.rb:X:in `foo' test.rb:X:in 'buggy_func': exception message ``` Is there any change to revert the change? ---------------------------------------- Feature #8661: Add option to print backstrace in reverse order(stack frames first & error last) https://bugs.ruby-lang.org/issues/8661#change-73573 * Author: gary4gar (Gaurish Sharma) * Status: Closed * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) * Target version: ---------------------------------------- Currently the way ruby prints the backtrace is that the error comes first & then the stack frames. like this ``` Main Error Message stack frame 1 stack frame 2 stack frame 3 ..... ``` this is perfectly fine provided 1. Backstraces are short, so fits in terminal.hence, no need to scroll. 2. you read it from top to bottom. But, I am a rails developer where 1. Backstraces are always HUGE, therefore seldom don't fit in terminal. Means LOTS of scrolling to do everytime we get an error. 2. in terminal we tend to read backstraces from bottom to top, especially when tailing(tail -f) the production logs. 3. people, who practice Test-driven development literally spend most of their time scrolling to read backstraces to the point most end up buying a larger display. Proposed Solution: Please add a way so we can configure backstraces to be printed in reverse order. so if you are reading from bottom, say from terminal, you can get the main error message without need to scroll. like this ``` stack frame 3 stack frame 2 stack frame 1 Main Error Message ..... ``` this would save lot of time because when the error message is print at the bottom, no need to scroll for reading it. Not sure if this can be done today. I tried Overriding Exception#backtrace but it caused stack level too deep & illegal hardware instruction Error. Attached are currently what backstrace currently looks like & how there be an option to make it look for comparison. ---Files-------------------------------- current.log (5.13 KB) proposed.log (4.9 KB) -- https://bugs.ruby-lang.org/