Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Logging improvements#1004

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
alonbl wants to merge2 commits intomicropython:master
base:master
Choose a base branch
Loading
fromalonbl:logging
Open

Conversation

@alonbl
Copy link
Contributor

logging: Support extra context for LogRecord.

Extra context is usable to enrich log record with concrete context
additions.


logging: move exc_info to common log.

The keyword parameters are populated to common log and exc_info should be
common to all methods anyway.

This change the default to be exc_info=False for all cases similar to the
standard python.

@alonbl
Copy link
ContributorAuthor

Anyone?

@Josverl
Copy link

Did you see my review comments?

@alonbl
Copy link
ContributorAuthor

Did you see my review comments?

Hi@Josverl ,

I do not see any comment made by anyone else but me in this ticket.

I would love to review any comment, can you please refer me where?

Thanks,
Alon

@JosverlJosverl self-requested a reviewOctober 23, 2025 19:37

classLogRecord:
defset(self,name,level,message):
def__init__(self,name,level,message,extra=None):
Copy link

@JosverlJosverlMay 2, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If the intend ofextra is to provide the same functionality as CPythonsLogRecord( ..., args, ...)
,then it makes sense to name it the same. That makes it simpler to learn.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Hi,
There is a inconsistency betweenLogRecord[1] andLogger.makeRecord[2].
It is "unknown" howextra reaches theLogRecord once constructed.
I can makeextra as property which is also not fully compatible.
I can havesetExtra().
I do not think this is that critical how we pass theextra into the record, as the interface is clearly not compatible, for example, we do not havemakeRecord or event population between loggers.
If you have a better notation, please let me know.
Thanks!

[1]https://docs.python.org/3/library/logging.html#logging.LogRecord
[2]https://docs.python.org/3/library/logging.html#logging.Logger.makeRecord

self.ct=time.time()
self.msecs=int((self.ct-int(self.ct))*1000)
self.asctime=None
ifextraisnotNone:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

can be simplified toif extra:

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Correct, but if you look closely in this source the pattern is to test for explicit None without having empty additional path. If it is important I will replace.

@Josverl
Copy link

Hi Alon,
I resubmitted my review and this time it shows up.
In addition, I think it would be helpful to add an example of how to add such context.

@JosverlJosverl added the enhancementFeature requests, new feature implementations labelOct 23, 2025
@alonbl
Copy link
ContributorAuthor

Hi Alon, I resubmitted my review and this time it shows up. In addition, I think it would be helpful to add an example of how to add such context.

Thanks! I will create an example.

Extra context is usable to enrich log record with concrete contextadditions.Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
The keyword parameters are populated to common log and exc_info should becommon to all methods anyway.This change the default to be exc_info=False for all cases similar to thestandard python.Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@JosverlJosverlJosverl requested changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

enhancementFeature requests, new feature implementations

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@alonbl@Josverl

[8]ページ先頭

©2009-2025 Movatter.jp