[Haskell-cafe] hslogger bugs or features - patches

Marc Weber marco-oweber at gmx.de
Mon Feb 2 17:56:07 EST 2009


> ======================================================================
> issue 1
> 
> That's not the most awkward thing:
>   When logging to "A.B.C" hslogger does add 3 loggers to the global
>   logger Map:
>   "A"
>   "A.B"
>   "A.B.C"
>   all three inheriting the default priority level of the default
>   rootLogger ""
> 
> A test application illustrating this (feature ?)
> 
>   module Main where
>   -- packages: hslogger
>   import  System.Log.Logger as HL
>   import  System.Log.Handler.Simple as HL
> 
>   main = do
>     -- the default logger logs to stderr level WARNING 
>     -- that's why the following message should be shown 
> 
>     -- a)
>     logM "A.B.C" HL.ALERT "ALERT test, should be shown and should create the sublogger"
> 
>     -- b)
>     updateGlobalLogger rootLoggerName (setLevel EMERGENCY)
> 
>     logM "A.B.C" HL.ALERT "ALERT test, should not be shown cause we have changed to EMERGENCY"
> 
> which prints:
> 
>   tmp %./test1
>   /tmp nixos   
>   ALERT test, should be shown and should create the sublogger
>   ALERT test, should not be shown cause we have changed to EMERGENCY

I've written some patches increasing speed by 30%. See the benchmark.
You can get them by cloning git://mawercer.de/hslogger;
(branch hslogger_updates)

I've replaced the internal representation (Map name Logger) by a tree.
Only logging to a logger does no longer add a new node (which cloned the
priority level in the past causing issue 1)

The basic interface
  updateLogger name (set priority or add handlers)
and 
  logM
is still the same. The logM is based on MonadIO now. So you no longer
have to call liftIO yourself..
  
Also I've removed the standard setup logging to stderr. There is a 
setupLogging function instead..
Why? I can think of some use cases where logging to stderr doesn't make
sense and it took me too much time figuring out how to remve the old
stderr logger (I didn't find a nice solution without changing the
exposed API)

I don't want to start using my "personal" copy of hslogger. That's why
I'd like to ask you wether you consider these changes beeing
improvements although they break existing code (You'll have do add that
initialization line)

I also wonder wether it's worth using Bytestrings instead of Strings?

I've not spend to much time on updating all the documentation yet..

If you'd like to ensure that a use case sill works add another test case
please.

You can also push to that git repository.

Sincerly
Marc Weber


More information about the Haskell-Cafe mailing list