Giter VIP home page Giter VIP logo

Comments (4)

vorner avatar vorner commented on August 15, 2024 1

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.

vorner avatar vorner commented on August 15, 2024 1

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.

jamestwebber avatar jamestwebber commented on August 15, 2024

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.

jamestwebber avatar jamestwebber commented on August 15, 2024

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.

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.