Return-Path: Delivered-To: apmail-directory-dev-archive@www.apache.org Received: (qmail 92285 invoked from network); 1 Sep 2005 17:38:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Sep 2005 17:38:23 -0000 Received: (qmail 56853 invoked by uid 500); 1 Sep 2005 17:38:22 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 56814 invoked by uid 500); 1 Sep 2005 17:38:22 -0000 Mailing-List: contact dev-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list dev@directory.apache.org Received: (qmail 56801 invoked by uid 99); 1 Sep 2005 17:38:21 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Sep 2005 10:38:21 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [211.24.132.29] (HELO f1.bali.ac) (211.24.132.29) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Sep 2005 10:38:36 -0700 Received: from [192.168.88.129] ([203.114.48.52]) (authenticated bits=0) by f1.bali.ac (8.12.8/8.12.8) with ESMTP id j81I1lq8001545 for ; Fri, 2 Sep 2005 02:01:49 +0800 From: Niclas Hedhman Organization: Independent To: "Apache Directory Developers List" Subject: Re: [OT] How best to respond to null arguments? Date: Fri, 2 Sep 2005 01:38:13 +0800 User-Agent: KMail/1.8 References: <4315F5B2.1070406@bellsouth.net> <200509020009.45264.niclas@hedhman.org> <1125592508.10209.11.camel@portable> In-Reply-To: <1125592508.10209.11.camel@portable> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200509020138.13491.niclas@hedhman.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N On Friday 02 September 2005 00:35, Emmanuel Lecharny wrote: > Using a good pattern in conjonction with slf4j could help a lot : > > if (arg =3D=3D null) > =C2=A0 =C2=A0 { > =C2=A0 =C2=A0 log.error("the third parameter ('history') is null"); > =C2=A0 =C2=A0 throw new IAE(); > =C2=A0 =C2=A0 } > ... > > As you can exhibit the method name and the line number with %C and %L, > it increases the message correctness. Very true, and my idea is to have a small utility that does the "trick" tha= t=20 Log4J does, i.e. fill in the stack, grab the second top element for "where= =20 was this detected" and the next element for "where was that called from"... The other thing, personally(!), I don't think any "library" (definition of= =20 what makes a library is a different story) should utilize logging framework= s=20 at all, be very conservative with any external output and instead rely on=20 exceptions and events to communicate such things. For instance, pass all su= ch=20 "log data" to a router class, where the user can register one or more Logge= rs=20 if she wants it. Cheers Niclas