question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

KeyError: "Attempt to overwrite 'args' in LogRecord"

See original GitHub issue

Expected result:

I am able to use args as keyword to denote argument to string interpolation when using loguru

Actual result:

Opposite of above 😉.In fact it seems that if you try to specify whatever is originally available in Record from logging of python, python will think you are crazy to put such things in record.

Facts

  • loguur.__version__ = 0.5.0
  • python --version = Python 3.7.6
  • lsb_release -sd = Linux Mint 19.3 Tricia
  • context = application

Reproduce

git clone https://github.com/kornicameister/axion.git /tmp/axion --depth 1 ; \
cd /tmp/axion ; \
git checkout c9d85e76bd48719aab7edded1d4287a52ecb145e \
command -v tox && tox -e "py37-test" -- -k test_not_empty_signature || echo "need tox" ; \
cd - \
rm -rf /tmp/axion

Root cause

Relevant line that causes issue available here

Alternatively, it might be caused by conftest#caplog here, but this is unlikely given that only one test fails 😉

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
Delgancommented, Jun 7, 2020

So, I modified the way the LogRecord is filled with extra.

The main downside is that it’s no longer possible to use Formatter("[%(some_extra_field)s] %(message)s") with standard logging handler, but I think it’s certainly less of a problem than the "Attempt to overwrite" error was.

Closing thie issue consequently. Discussion about mypy plugins moved here: #277

1reaction
Delgancommented, May 22, 2020

There exists type hints for loguru, anyone should be able to benefit from it using mypy, right?

I opened https://github.com/kornicameister/axion/issues/328 to discuss usage of loguru in your project. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Why is it forbidden to override log record attributes?
Looking at the _ _ init _ _() method in that file, we can see that it sets a long list of attributes,...
Read more >
logging.error('asdf', extra={'msg':123}) raise KeyError exception
KeyError : "Attempt to overwrite 'msg' in LogRecord" Originally code was extra=locals() and 'msg' was local variable, but it doesn't matter.
Read more >
logging — Pyrocko v2020.10.26 Manual
The main information passed in is in msg and args, which are combined using ... __dict__): raise KeyError("Attempt to overwrite %r in LogRecord"...
Read more >
Python Examples of logging.LogRecord - ProgramCreek.com
Args : record: logging.LogRecord, the record to get ... __dict__): raise KeyError("Attempt to overwrite %r in LogRecord" % key) rv.__dict__[key] = extra[key] ...
Read more >
API Reference - structlog 22.3.0 documentation
LogRecord objects to the event dictionary. This processor can be used for adding data passed in the extra parameter of the logging module's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found