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

Pylance type checking complains about structured logging on the standard logger #40

Open
markledwich2 opened this issue Sep 8, 2021 · 2 comments

Comments

@markledwich2
Copy link

Pylance now reports problems that each of the parameters do not exist

log.info('hello {name}',  name='Mark')

Error shown: No parameter named "name" (Pylance reportGeneralTypeIssues)

I asked them and they said that I should use a seq specific log function from seqlog instead of the standard one. What would be your recommended way to use seqlog and also have pylances type checking enabled?

@Vacant0mens
Copy link
Collaborator

Sorry for the delayed response to your issue.

The Pylance team was correct, in the stdlib logging module the level-based functions support **kwargs, but the base log function doesn't. **kwargs is implemented in seqlog's main log function to add properties to what it sends to the Seq server, but those properties are not passed back to the stdlib logging module functions.

How are you initializing the logging or seqlog modules?

If you don't use override_root_logger=True when you call log_to_seq() the standard logging.info() function would send the logs to the default/root logger, which is not the seqlog logger.

Looks like you were calling log.info() though, so I'm curious: how are you initializing the logging and/or seqlog modules? Could you provide a little context?

@Vacant0mens
Copy link
Collaborator

This issue seems the same as #41. which has a bit more in-depth discussion about this topic.

Also the official documentation for the stdlib logging module uses args (when provided) to merge into msg before returning the string via getMessage() or logging it via log().

The seqlog documentation may need an update in this regard (at least for clarity's sake), but technically there is a name argument for a log record that's separate from the args argument, but it's for telling the main logging module which logger to send the log to.

I'll see about updating the documentation here to reflect the above details.

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

2 participants