Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging: allow multiple entries in qualname config #55338

Closed
techtonik mannequin opened this issue Feb 5, 2011 · 8 comments
Closed

logging: allow multiple entries in qualname config #55338

techtonik mannequin opened this issue Feb 5, 2011 · 8 comments
Assignees

Comments

@techtonik
Copy link
Mannequin

techtonik mannequin commented Feb 5, 2011

BPO 11129
Nosy @vsajip

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/vsajip'
closed_at = <Date 2011-02-07.09:10:09.524>
created_at = <Date 2011-02-05.14:44:42.375>
labels = []
title = 'logging: allow multiple entries in qualname config'
updated_at = <Date 2017-07-25.03:44:21.891>
user = 'https://bugs.python.org/techtonik'

bugs.python.org fields:

activity = <Date 2017-07-25.03:44:21.891>
actor = 'cmcqueen1975'
assignee = 'vinay.sajip'
closed = True
closed_date = <Date 2011-02-07.09:10:09.524>
closer = 'vinay.sajip'
components = []
creation = <Date 2011-02-05.14:44:42.375>
creator = 'techtonik'
dependencies = []
files = []
hgrepos = []
issue_num = 11129
keywords = []
message_count = 8.0
messages = ['127992', '128105', '128149', '128164', '128166', '128169', '220939', '220953']
nosy_count = 4.0
nosy_names = ['vinay.sajip', 'dsuch', 'techtonik', 'cmcqueen1975']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue11129'
versions = ['Python 2.7']

@techtonik
Copy link
Mannequin Author

techtonik mannequin commented Feb 5, 2011

When configuration is specified in external file, qualname attribute should allow several values. Maybe comma separated.

@vsajip
Copy link
Member

vsajip commented Feb 7, 2011

There's no particularly good use case for this. Plus, going forwards, dictionary-based configuration should be used (as it supports more logging features).

@vsajip vsajip closed this as completed Feb 7, 2011
@vsajip vsajip self-assigned this Feb 7, 2011
@techtonik
Copy link
Mannequin Author

techtonik mannequin commented Feb 7, 2011

Where is this configuration?

@vsajip
Copy link
Member

vsajip commented Feb 8, 2011

See PEP-391. Documentation is at

http://docs.python.org/library/logging.html#configuration

as you might expect.

@techtonik
Copy link
Mannequin Author

techtonik mannequin commented Feb 8, 2011

And how do you intend to parse the dictionary stored in external file? Evaluating this script is unsafe.

@techtonik techtonik mannequin added the type-security A security issue label Feb 8, 2011
@vsajip
Copy link
Member

vsajip commented Feb 8, 2011

The logging package will not parse any external file to get a dictionary. It's up to the application developer to provide a dictionary which will be used for configuration, so there's no security issue in the stdlib.

@vsajip vsajip removed the type-security A security issue label Feb 8, 2011
@dsuch
Copy link
Mannequin

dsuch mannequin commented Jun 18, 2014

Hello friends,

@vinay.sajip - the use case for this feature is actually something I come across fairly often.

In an application I have dozens and hundreds of logger instances. However, they all fall into one of several loggers.

Most of the instances are obtained through a module-wide logger = getLogger(name).

Now I have a feature in the application split over a couple of modules, in different namespaces:

zato.common.scheduler
zato.server.scheduler

They are independent yet related and it would be most convenient if I could list both in qualname - they really should share the logging configuration, at no point they should have separate handlers, logging formats, anything.

As an aside, regarding dict configuration - I know you made the comment in 2011 so it may not represent your current opinion but please keep in mind that logging config is something that on production is updated by administrators, i.e. whatever the latest trends in software development are, they aren't necessarily programmers.

People I work with have no problems with customizing ini-like files but Python dicts are an entirely different story, they are simply afraid of doing it - a missing apostrophe may mean a couple of hours wasted, for instance.

@vsajip
Copy link
Member

vsajip commented Jun 18, 2014

they really should share the logging configuration

Well, that's easy enough to do - although there would be some duplication in the .ini file, it is not especially onerous. While I well understand the benefits of DRY, I still don't believe this is a very common use case, and there are other ways of doing this: for example, using a logger called zato.scheduler from both scheduler modules. I know that __name__ for naming loggers is a good approach in almost all cases, it's not absolutely mandatory. What I don't want to do is to keep adding functionality (which I will then have to maintain) to an older mechanism when a newer and better one is available. And using dictConfig() doesn't have to mean users/administrators editing Python source code by hand - for example, YAML could be used, or JSON. Or, use .ini but parse the file in your code and build a dict to pass to dictConfig(). Then you can use any schema you want, plus support things like Filters which fileConfig() doesn't do.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant