Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jakkusakura/tracing-shared-rs
https://github.com/jakkusakura/tracing-shared-rs
Last synced: about 6 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/jakkusakura/tracing-shared-rs
- Owner: JakkuSakura
- License: mit
- Created: 2024-02-21T15:55:41.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-09-20T19:39:12.000Z (4 months ago)
- Last Synced: 2024-12-30T20:59:04.500Z (17 days ago)
- Language: Rust
- Size: 16.6 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tracing-shared-rs
Share a logger between a dylib/cdylib and the main binary
## Usage
```toml
[dependencies]
tracing-shared = "0.1"```
checkout examples/example.rs
### cdylib's case
```rust
use tracing_shared::SharedLogger;fn main() {
let dylib = unsafe { libloading::Library::new(dylib) }.expect("error loading dylib");
let setup_logger: FnSetupLogger = unsafe { *dylib.get(b"setup_shared_logger_ref").unwrap() };
let run: FnRun = unsafe { *dylib.get(b"run").unwrap() };
let logger = SharedLogger::new();
setup_logger(&logger);
run("cdylib")
}
```### dylib's case
```rust
use tracing_shared::SharedLogger;fn main() {
let logger = SharedLogger::new();
example_lib::setup_shared_logger_ref(&logger);
example_lib::run("dylib");
}
```