Re: tools.py: patch to fix make_log/log for python installations with logging module

Bob Ippolito <bob-Zl9L/[email protected]>
Newsgroups gmane.comp.web.pyblosxom.devel
Message-ID <[email protected]>
It's not just clearer, but more correct, to use the named functions.  
On Win32, as far as Python is concerned, both '/' and '\\' are valid 
separator characters.  Splitting on os.sep only considers '\\'.

-bob

On Dec 10, 2004, at 1:07 PM, Bill Mill wrote:

> Steven,
>
> looks nice, and that seems like a better log() function. If I could
> make one suggestion, could you change the line:
>
> loggerName = filename.split(os.sep)[-1:][0].split(".")[0]
>
> to:
>
> logger_name = os.path.splitext(os.path.basename(filename))[0]
>
> It seems clearer to me if you use the named functions from os.path to
> achieve the same thing. Just a thought.
>
> Peace
> Bill Mill
> bill.mill at gmail.com
>
>
> On Fri, 10 Dec 2004 12:54:11 +0100, Steven Armstrong <[email protected]> 
> wrote:
>> Hi all
>>
>> The subject is the message.
>>
>> cheers
>> Steven
>>
>>
>> Index: tools.py
>> ===================================================================
>> RCS file: /cvsroot/pyblosxom/pyblosxom/Pyblosxom/tools.py,v
>> retrieving revision 1.37
>> diff -u -r1.37 tools.py
>> --- tools.py    8 Dec 2004 01:20:07 -0000       1.37
>> +++ tools.py    10 Dec 2004 11:42:41 -0000
>> @@ -511,15 +511,21 @@
>>              f.write("\n")
>>              f.close()
>>      else:
>> -        logger = logging.getLogger('trackback')
>> +        # if all loggers have the same name,
>> +        # everything is logged to all files.
>> +        loggerName = filename.split(os.sep)[-1:][0].split(".")[0]
>> +        logger = logging.getLogger(loggerName)
>>          hdlr = logging.FileHandler(filename)
>>          formatter = logging.Formatter('%(asctime)s %(levelname)s 
>> %(message)s')
>>          hdlr.setFormatter(formatter)
>>          logger.addHandler(hdlr)
>>          logger.setLevel(logging.INFO)
>>
>> -        def log(str):
>> -            logger.info(str)
>> +        def log(*args):
>> +            # adjusted to match the 'manual' log func
>> +            for i in args:
>> +                logger.info(repr(i))
>> +
>>
>>  def update_static_entry(cdict, entry_filename):
>>
>>
>>
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real 
> users.
> Discover which products truly live up to the hype. Start reading now.
> http://productguide.itmanagersjournal.com/
> _______________________________________________
> Pyblosxom-devel mailing list
> Pyblosxom-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/pyblosxom-devel



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.