Re: tools.py: patch to fix make_log/log for python installations with logging module
Bill Mill <[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.devel |
|---|---|
| Message-ID | <[email protected]> |
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/