Dependency injection: overriding defaults

Kushal Kumaran kushal at locationd.net
Thu Feb 1 15:28:15 EST 2018


Victor Porton <porton at narod.ru> writes:

> dieter wrote:
>
>> Victor Porton <porton at narod.ru> writes:
>> 
>>> I am writing a library, a command line utility which uses the library,
>>> and a I am going to use dependency_injector package.
>>>
>>> Consider loggers:
>>>
>>> For the core library the logger should default to stderr.
>>>
>>> For the command line utility, we use the default logger of the library.
>>>
>>> For the server, the log should go to a file (not to stderr).
>>>
>>> Question: How to profoundly make my software to use the appropriate
>>> logger, dependently on whether it is a command line utility or the
>>> daemon?
>> 
>> I would distinguish between the common library and distinct
>> applications (command line utility, daemon). The applications
>> configure the logging system (differently) while the library uses
>> uniform logging calls.
>
> You have essentially just repeated my requirements.
>
> But HOW to do this (using dependency_injector module)?
>

No idea how dependency_injector affects this, but have you read the
logging howto? The section
https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library
would be appropriate.

-- 
regards,
kushal



More information about the Python-list mailing list