[ckan-dev] Logging in commands question

David Read david.read at okfn.org
Wed Apr 6 15:58:30 UTC 2011


On 6 April 2011 17:36, William Waites <ww at styx.org> wrote:
> * [2011-04-06 17:02:06 +0200] David Read <david.read at okfn.org> écrit:
>
> ] In which case, you could try to put the function in a
> ] separate python file and all clients import that. I think this would
> ] avoid the problems with ordering of imports and setup of module
> ] variables that I think are shown in your examples.
> ] http://effbot.org/pyfaq/how-do-i-share-global-variables-across-modules.htm
>
> Two problems with this. Firstly the whole point of using getLogger
> is to set the logging prefix which should be local to the file
> (actually even better if it is local to the function so you can
> really tell where log messages are coming from).

Yes, this was my first point. My second point relied on assuming Adria
knows the first already and has another reason for wanting to run
logging through a unified function.

> Second problem is if you use global variables like this it gets
> extremely side-effecty and difficult to know what is going on. There
> is a very good discussion of this phenomenon in the pyramid docs:
>
> http://docs.pylonsproject.org/projects/pyramid/dev/designdefense.html#application-programmers-don-t-control-the-module-scope-codepath-import-time-side-effects-are-evil

Sure, there are issues with globals, but in this case I'm not sure we
need to worrying about the config file being imported twice and thus
redefining the logging function.

Anyway, this is rather by the by - perhaps we shouldn't do too much
hypothesizing when we don't know what Adria is trying to achieve.

David

>
> Cheers,
> -w
>
> --
> William Waites                <mailto:ww at styx.org>
> http://river.styx.org/ww/        <sip:ww at styx.org>
> F4B3 39BF E775 CF42 0BAB  3DF0 BE40 A6DF B06F FD45
>




More information about the ckan-dev mailing list