Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Logging in Rust code not working (in unit tests?) #14975

Closed
clokep opened this issue Feb 2, 2023 · 1 comment · Fixed by #14976
Closed

Logging in Rust code not working (in unit tests?) #14975

clokep opened this issue Feb 2, 2023 · 1 comment · Fixed by #14976
Assignees
Labels
O-Occasional Affects or can be seen by some users regularly or most users rarely S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.

Comments

@clokep
Copy link
Member

clokep commented Feb 2, 2023

We use pyo3-log to get Rust logs into the Python logging framework; this seems to not work properly. If you put e.g. a warn!(...) then it doesn't print out anywhere.

We initialize the logging module in lib.rs:

pyo3_log::init();

And we import the synapse rust code very early in the Synapse process:

check_rust_lib_up_to_date()


I think we're importing the rust code before the loggers are configured, which then causes pyo3-log to initialize and cache the Python logging configuration, then by the time we actually call Rust code we've reconfigured the python loggers, but that doesn't propagate into Rust.

I ran into this in unittests, but I think it would happen during normal usage as well.

@clokep
Copy link
Member Author

clokep commented Feb 2, 2023

A potential solution might be to "re-initialize" the pyo3-log each time we reload the logging config?

@clokep clokep self-assigned this Feb 2, 2023
@clokep clokep added S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. O-Occasional Affects or can be seen by some users regularly or most users rarely labels Feb 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
O-Occasional Affects or can be seen by some users regularly or most users rarely S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant