Comments (4)
Hello
It would be the first suspect to investigate for me too. You can try either creating another logger for space
and see if that helps, change the structure of the rust code to generate the right package name or set the target on the rust side manually with something like:
info!(target: "name.space", "stuff");
(and possibly create your own macro wrappers so you don't have to repeat it everywhere)
from pyo3-log.
The target
is an attribute of each log record (you can have multiple targets inside the same binary), it's not something I'd have in hand with pyo3-log (https://docs.rs/log/latest/log/struct.Metadata.html#method.target). Most probably, if your rust code has some other dependencies, these may be logging in their own targets and there's a lot more log messages flying around in there, not getting logged because no logger on the python side matches them.
As for the structure of the code… the target is generated based on the crate name and the file under it, so I think you would need something like a name
crate with space.rs
in it (and lib.rs
being just a wrapper around that). That would generate a target of name::space
and that ::
separator gets replaced with .
in pyo3-log.
from pyo3-log.
Ah the target
argument works great!
change the structure of the rust code to generate the right package name
I guess I'm just not sure how to do this correctly. I've added module-name
to my maturin build (as name.space._space
). The crate name can't have a dot in it, so I can't just name the pyo3 module name.space
directly.
If there's a way to make the name correct that's my preferred option. Otherwise, it'd be a nice enhancement I could pass my target on init rather than in every logging message. But if that's not feasible, it's not too bad for me to do it myself.
from pyo3-log.
As for the structure of the code… the target is generated based on the crate name and the file under it, so I think you would need something like a
name
crate withspace.rs
in it (andlib.rs
being just a wrapper around that). That would generate a target ofname::space
and that::
separator gets replaced with.
in pyo3-log.
Ah, this is a good solution. I was worried that defining the name
crate would cause conflicts with other packages in the namespace, but the crate's name doesn't really matter in python-land.
For anyone searching in the future: if I want to create more pyo3-based packages in the same namespace, I can have each one follow this pattern (e.g. a package named scape
):
pysrc/
name/
scape/
__init__.py
...
src/
lib.rs # just contains "mod scape;"
scape.rs
Where cargo.toml
thinks the lib is called name
but pyproject.toml
renames the extension module to something like name.scape._scape
. All this to get the logging messages to look pretty. 😂
from pyo3-log.
Related Issues (15)
- Logging from pure Rust HOT 6
- Migrate to pyo3 0.13 HOT 3
- Document interaction with starting other threads in Rust HOT 3
- PyO3 0.15 support. HOT 4
- TypeError: not all arguments are converted during string formatting HOT 1
- `pyo3_init` resulting in a segementation fault HOT 9
- Change logging level during runtime HOT 4
- tracing compatibility HOT 1
- Tag 0.8.1 HOT 1
- LogRecords are instantiated with `None` for args HOT 3
- Emitting a `log` message during interpreter finalization will cause a panic HOT 1
- `log_enabled!` macro behavior HOT 2
- Not compatible with pyo 0.21.1
- pyo3 v0.22.0 has been released HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyo3-log.