Integrate logging in the Python wrapper

This commit is contained in:
Oliver Hamlet
2025-03-25 22:02:34 +00:00
parent 2076478a4f
commit e61aeabfbb
5 changed files with 24 additions and 55 deletions
Generated
+18
View File
@@ -35,6 +35,12 @@ version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
[[package]]
name = "arc-swap"
version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457"
[[package]]
name = "arraydeque"
version = "0.5.1"
@@ -623,6 +629,7 @@ dependencies = [
"libloot",
"libloot-ffi-errors",
"pyo3",
"pyo3-log",
]
[[package]]
@@ -894,6 +901,17 @@ dependencies = [
"pyo3-build-config",
]
[[package]]
name = "pyo3-log"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b78e4983ba15bc62833a0e0941d965bc03690163f1127864f1408db25063466"
dependencies = [
"arc-swap",
"log",
"pyo3",
]
[[package]]
name = "pyo3-macros"
version = "0.24.0"
+1 -23
View File
@@ -1,28 +1,6 @@
# libloot-rs
This is an **incomplete** and **experimental** reimplementation of [libloot](https://github.com/loot/libloot) using Rust instead of C++.
## Current status
Currently complete:
- [x] Public API types and function declarations
- [x] Public API doc comments
- [x] Library versioning
- [x] Setting a logging callback
- [x] Parsing metadata from YAML
- [x] Serialising metadata to YAML
- [x] Game-related functionality
- [x] Plugin-related functionality
- [x] Archive-related functionality
- [x] Metadata-related functionality (excluding writing YAML)
- [x] Sorting functionality
- [x] Unit tests
- [x] Integration tests
- [x] C++ FFI
- [ ] Python FFI
The complete bits should match libloot v0.25.5.
This is an **experimental** reimplementation of [libloot](https://github.com/loot/libloot) using Rust instead of C++, that should match libloot v0.25.5.
## Build
+1
View File
@@ -12,3 +12,4 @@ crate-type = ["cdylib"]
libloot = { path = ".." }
libloot-ffi-errors = { path = "../ffi-errors" }
pyo3 = "0.24.0"
pyo3-log = "0.12.2"
+2 -32
View File
@@ -1,37 +1,6 @@
# libloot-pyo3
An **incomplete** and **experimental** Python wrapper around the libloot Rust implementation, built using [PyO3](https://pyo3.rs).
## Current coverage
- [x] `LIBLOOT_VERSION_MAJOR`
- [x] `LIBLOOT_VERSION_MINOR`
- [x] `LIBLOOT_VERSION_PATCH`
- [x] `is_compatible()`
- [x] `libloot_revision()`
- [x] `libloot_version()`
- [ ] `set_logging_callback()`
- [ ] `set_log_level()`
- [x] `EdgeType`
- [x] `GameType`
- [ ] `LogLevel`
- [x] `Database`
- [x] `Game`
- [x] `Plugin`
- [x] `Vertex`
- [x] `File`
- [x] `Filename`
- [x] `Group`
- [x] `Location`
- [x] `Message`
- [x] `MessageContent`
- [x] `PluginCleaningData`
- [x] `PluginMetadata`
- [x] `Tag`
- [x] `MessageType`
- [x] `TagSuggestion`
- [x] `select_message_content()`
- [x] Error types
An **experimental** Python wrapper around the libloot Rust implementation, built using [PyO3](https://pyo3.rs).
## Build
@@ -64,3 +33,4 @@ py
- The API provides the custom `CyclicInteractionError`, `UndefinedGroupError`, `EspluginError` exception types.
- All other errors are raised as `ValueError` exceptions.
- There's no equivalent to the C++ interface's `FileAccessError` or `ConditionSyntaxError` classes or the libloadorder and loot-condition-interpreter system error categories.
- The `LogLevel` enum and `set_logging_callback()` and `set_log_level()` functions are not exposed because the logging is integrated with Python's `logging` module instead.
+2
View File
@@ -35,6 +35,8 @@ create_exception!(loot, EspluginError, PyException);
/// A Python module implemented in Rust.
#[pymodule(name = "loot")]
fn libloot_pyo3(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
pyo3_log::init();
m.add("LIBLOOT_VERSION_MAJOR", libloot::LIBLOOT_VERSION_MAJOR)?;
m.add("LIBLOOT_VERSION_MINOR", libloot::LIBLOOT_VERSION_MINOR)?;
m.add("LIBLOOT_VERSION_PATCH", libloot::LIBLOOT_VERSION_PATCH)?;