From notifications-return-10793-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Mon Jan 15 23:03:07 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 7D25F180657 for ; Mon, 15 Jan 2018 23:03:07 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 6C216160C31; Mon, 15 Jan 2018 22:03:07 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B0A1A160C1C for ; Mon, 15 Jan 2018 23:03:06 +0100 (CET) Received: (qmail 94405 invoked by uid 500); 15 Jan 2018 22:03:05 -0000 Mailing-List: contact notifications-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list notifications@groovy.apache.org Received: (qmail 94396 invoked by uid 99); 15 Jan 2018 22:03:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jan 2018 22:03:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 7DC5EC75D8 for ; Mon, 15 Jan 2018 22:03:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.711 X-Spam-Level: X-Spam-Status: No, score=-100.711 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id NPeD7vQbzs4c for ; Mon, 15 Jan 2018 22:03:04 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 0E0A95FAC9 for ; Mon, 15 Jan 2018 22:03:04 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 98E57E01A7 for ; Mon, 15 Jan 2018 22:03:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 3918320DF3 for ; Mon, 15 Jan 2018 22:03:00 +0000 (UTC) Date: Mon, 15 Jan 2018 22:03:00 +0000 (UTC) From: =?utf-8?Q?Leonard_Br=C3=BCnings_=28JIRA=29?= To: notifications@groovy.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (GROOVY-8431) toDebugString method as a core concept MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/GROOVY-8431?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D163= 26595#comment-16326595 ]=20 Leonard Br=C3=BCnings commented on GROOVY-8431: ------------------------------------------ While not supporting this feature, I'd suggest to use a {{ToStringHelper}} = similar to guava instead of some parameters like String toDebugString(int indentationLevel, String indentationString =3D '\t= ') this way we can be flexible, while having a standard api/way to output stru= ctured content. The {{DebugStringBuilder}} would be an interface with a def= ault implementation, a developer/tool could choose to supply a different im= plementation for their needs. The GroovyObject would add a default=C2=A0{{t= oDebugString()}} method that in turn calls the overridable {{toDebugString(= DebugStringBuilder builder)}} > toDebugString method as a core concept > -------------------------------------- > > Key: GROOVY-8431 > URL: https://issues.apache.org/jira/browse/GROOVY-8431 > Project: Groovy > Issue Type: Proposal > Components: GEP, groovy-jdk > Affects Versions: 3.x, 2.5.x > Reporter: mgroovy > Priority: Major > Labels: features > > * Groovy should introduce a toDebugString method as a core concept, to se= parate debug to-string-conversion semantics from heavily oversubscribed sta= ndard Java Object#toString. > * The power of this feature as a core concept lies in support to create > ## Easy to use, human readable debug output of any object > ## Creating debug output of objects owned by other objects (i.e. hierarch= ical debug output) > * Adding this feature should be relatively simple, the challenge is to de= cide what features/parameters toDebugString should have, because this will = be hard to change once the feature has been introduced. =20 > * The default implementation could > ## Call the Java default Object#toString method > ## Automatically create a reflection based output (performance will proba= bly be bad for this, so it might be better to enable this behavior through = an annotation) > ## Returns something along the line of getClass().simpleName + '@' + Syst= em.identityHashcode(this) (though Object#toString is probably more useful) > ## Fall back to the class' toString method (although in most cases it's m= ost likely not what the user wants/expects) > * An extension would be for an overloaded toDebugString to take an indent= ationLevel and indentationString parameter: > {code}String toDebugString(int indentationLevel, String indentationString= =3D '\t'){code} > ** Implementations would be expected to indent the resulting String accor= dingly, which is very helpful for > ### Complex objects which require a multi-line output to make sense of th= em in a debug log > ### Outputting inner objects (e.g. a collection) owned by an object > ** Groovy default implementation could be, to indent the result of callin= g toDebugString(), by scanning for newline sequences in the returned string > * Questions: > ## Is there a better name than the (relatively long) "toDebugString" ? > *** toDebugString was suggested, since it is easy to discover, and its pu= rpose should immediately clear > ## Should the return type of toDebugString be GString instead of String ? > *** This would allow for Groovy to process the objects embedded in the GS= tring differently > *** Having an additional GString toDebugGString() method might be an alte= rnative > ## Should there be additional parameters such as a terseness/verboseness = parameter, which indicates how compact or verbose the generated debug strin= g should be (implementations would be free to ignore this, of course) ? -- This message was sent by Atlassian JIRA (v7.6.3#76005)