gnulnx / django-mongolog

A Simple Mongo Based Logger for Django
http://gnulnx.github.io/django-mongolog/
GNU General Public License v3.0
15 stars 4 forks source link

wording of ValueError upon misnamed logger #72

Closed codekiln closed 5 years ago

codekiln commented 5 years ago

I encountered the following error when I misunderstood the purpose of the logger argument to Mongolog.find(logger="badger"...), where I entered the Mongo collection name badger instead of the different logger name "mustelidae" or whatever:

ValueError at /path/to/error/url/
No BaseMongoLogHandler could be found.  Did you add on to youy logging config?

Given this:

results = Mongolog.find(
    logger='badger',
    query={
        'msg.jobid': str(jobid),
    },
    project={
        '_id': 0,
        'output': '$msg.output',
        'jobid': '$msg.jobid',
        'cmd': '$msg.cmd'
    },
)

If the badger logger isn't found in Django logging settings, perhaps a more instructive error message would be: "Please check that LOGGERS["loggers"]["badger"] is defined in your Django settings and that it points to a logging handler of class mongolog.SimpleMongoLogHandler.

gnulnx commented 5 years ago

Thanks for the feedback. Changes in this pr https://github.com/gnulnx/django-mongolog/pull/73

will be in next release.