Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #21805

Re: ultralog: new concept of logging API

From Leif Roar Moldskred <leifm@dimnakorr.com>
Subject Re: ultralog: new concept of logging API
Newsgroups comp.lang.java.programmer
References <0cfefb99-94f9-44e0-9b58-926818a9560d@googlegroups.com> <ke3s9v$md5$1@dont-email.me> <78bfbd4c-a257-44ed-ae03-73ceb19fab18@googlegroups.com>
Message-ID <J_2dnYO2VrzAGJjMnZ2dnUVZ8oqdnZ2d@giganews.com> (permalink)
Date 2013-01-27 13:51 -0600

Show all headers | View raw


vladimirow@mail.ru wrote:
> For me the following:
> 
>    logger.userLoggedIn (userName, address);
> 
> is clearer than
> 
>    logger.info ("User `" + userName + "' logged in from " + address);
> 
> or
> 
>    logger.info ("User `{}' logged in from {}", userName, address);
> 
> or
> 
>    logger.infoT ("User `{}' logged in from {}").p (userName).p (address).endT ();
> 
> Anyway this is matter of personal preference.

Actually, I disagree with both claims, but regardless, even if you
prefer the first version, I fail to see the advantage in your way of
doing it compared to just doing this:


public SomeResult someMethod( Argument anArg ) {
  /* Boring business stuff */
  Result aResult = ...

  /* Exciting logging stuff */
  logResultDigest( anArg, aResult ); 

  return aResult;
} 

private void logResultDigest( Argument arg, SomeResult result ) {
  String orderID = arg.getOrder().getID();
  if( yeOldeLogger.isDebugEnabled() ) {
    String resultDigest = expensiveDigestCalculation( result );
    yeOldeLogger.debug( "Processed order {} in process {}. Result digest :  {}",
                        orderID, this.processID, resultDigest ); 
  }
  else {
    yeOldeLogger.info( "Processed order {} in process {}.", 
    		       orderID, this.processID );     
  }
}

To me, your way of doing it just introduces a pointless extra layer of
indirection into the code which provides little actual benefit. In my
experience, a particular log message is almost always tied to only one
specific point in the code, so it makes no sense to abstract it out
into an interface. (I actually think a good argument can be made that
writing identical log messages from multiple points in the good is a
strong suggestion that either your code is badly structured and should
be refactored, or that your logging scheme is badly thought out and
uninformative.)

-- 
Leif Roar Moldskred

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

ultralog: new concept of logging API Mikhail Vladimirov <vladimirow@mail.ru> - 2013-01-26 22:05 -0800
  Re: ultralog: new concept of logging API markspace <markspace@nospam.nospam> - 2013-01-27 10:39 -0800
    Re: ultralog: new concept of logging API vladimirow@mail.ru - 2013-01-27 11:03 -0800
      Re: ultralog: new concept of logging API Joerg Meier <joergmmeier@arcor.de> - 2013-01-27 20:48 +0100
        Re: ultralog: new concept of logging API Mikhail Vladimirov <vladimirow@mail.ru> - 2013-01-27 20:15 -0800
      Re: ultralog: new concept of logging API Leif Roar Moldskred <leifm@dimnakorr.com> - 2013-01-27 13:51 -0600
        Re: ultralog: new concept of logging API Mikhail Vladimirov <vladimirow@mail.ru> - 2013-01-27 19:57 -0800
  Re: ultralog: new concept of logging API Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-01-28 05:23 -0400
    Re: ultralog: new concept of logging API Mikhail Vladimirov <vladimirow@mail.ru> - 2013-01-28 01:32 -0800
      Re: ultralog: new concept of logging API Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-01-28 05:37 -0400
        Re: ultralog: new concept of logging API Mikhail Vladimirov <vladimirow@mail.ru> - 2013-01-28 02:06 -0800
      Re: ultralog: new concept of logging API Lew <lewbloch@gmail.com> - 2013-01-28 13:49 -0800
        Re: ultralog: new concept of logging API Mikhail Vladimirov <vladimirow@mail.ru> - 2013-01-29 06:04 -0800
          Re: ultralog: new concept of logging API Lew <lewbloch@gmail.com> - 2013-01-29 10:19 -0800
          Re: ultralog: new concept of logging API Leif Roar Moldskred <leifm@dimnakorr.com> - 2013-01-29 13:10 -0600
            Re: ultralog: new concept of logging API Mikhail Vladimirov <vladimirow@mail.ru> - 2013-01-29 11:34 -0800
              Re: ultralog: new concept of logging API Arne Vajhøj <arne@vajhoej.dk> - 2013-01-29 20:16 -0500
                Re: ultralog: new concept of logging API Mikhail Vladimirov <vladimirow@mail.ru> - 2013-01-29 19:57 -0800
                Re: ultralog: new concept of logging API Lew <lewbloch@gmail.com> - 2013-01-29 22:56 -0800
                Re: ultralog: new concept of logging API Mikhail Vladimirov <vladimirow@mail.ru> - 2013-01-29 23:19 -0800
                Re: ultralog: new concept of logging API Lew <lewbloch@gmail.com> - 2013-01-30 08:23 -0800
                Re: ultralog: new concept of logging API lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-01-30 16:54 +0000
                Re: ultralog: new concept of logging API Mikhail Vladimirov <vladimirow@mail.ru> - 2013-01-30 13:33 -0800
                Re: ultralog: new concept of logging API tisue@cs.nwu.edu (Seth Tisue) - 2013-01-30 16:37 -0500
                Re: ultralog: new concept of logging API tisue@cs.nwu.edu (Seth Tisue) - 2013-01-30 16:33 -0500
                Re: ultralog: new concept of logging API Arne Vajhøj <arne@vajhoej.dk> - 2013-01-30 21:50 -0500
                Re: ultralog: new concept of logging API lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-01-31 10:38 +0000
                Re: ultralog: new concept of logging API T®oll <spooksRus@derbyshire-crania.org> - 2013-01-31 12:30 -0500
                Re: ultralog: new concept of logging API T®oll <spooksRus@derbyshire-crania.org> - 2013-01-31 12:30 -0500
                Re: ultralog: new concept of logging API lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-01-31 17:55 +0000
                Re: ultralog: new concept of logging API lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-01-31 10:48 +0000
                Re: ultralog: new concept of logging API T®oll <spooksRus@derbyshire-crania.org> - 2013-01-31 12:32 -0500
                Re: ultralog: new concept of logging API lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-01-31 17:58 +0000
                Re: ultralog: new concept of logging API Mikhail Vladimirov <vladimirow@mail.ru> - 2013-01-31 21:49 -0800
                Re: ultralog: new concept of logging API Arne Vajhøj <arne@vajhoej.dk> - 2013-01-30 21:47 -0500
                Re: ultralog: new concept of logging API Mikhail Vladimirov <vladimirow@mail.ru> - 2013-01-30 21:14 -0800
                Re: ultralog: new concept of logging API Arne Vajhøj <arne@vajhoej.dk> - 2013-01-30 21:43 -0500
                Re: ultralog: new concept of logging API Mikhail Vladimirov <vladimirow@mail.ru> - 2013-01-30 21:11 -0800
  Re: ultralog: new concept of logging API Mikhail Vladimirov <vladimirow@mail.ru> - 2013-01-30 13:43 -0800

csiph-web