1 unstable release
0.1.0 | Jun 15, 2023 |
---|
#732 in Debugging
39 downloads per month
65KB
482 lines
Contains (JAR file, 61KB) java/gradle/wrapper/gradle-wrapper.jar
Tracing SLF4j
SLF4j backend compatible with Rust's tracing crate.
Purpose
The purpose of this crate is to allow Rust programs that embed Java programs to receive logging from the Java parts, if those parts are using SLF4j.
Compiling
This crate requires a Java compiler installed. the JAVA_HOME
environmental variable should be set.
Usage
When using JNI's invocation API, the JAR file embedded in this crate should be added to the classpath:
- Save the jarfile (const
DEPENDENCIES
) to disk - Add the option
-Djava.class.path=<PATH TO JARFILE>
to the JVM's start parameters.
After the JVM has been started, the setup register_log_fn
function should be called:
tracing_slf4j::register_log_fn(&mut env).unwrap();
This function will register the Rust logging handler with the JVM.
lib.rs
:
tracing-slf4j
SLF4j backend compatible with Rust's tracing crate. Allows Java programs started from your program to log their logs to Rust's tracing.
Usage
When using JNI's invocation API, the JAR file embedded in this crate should be added to the classpath:
- Save the jarfile (const
tracing_slf4j::DEPENDENCIES
) to disk - Add the option
-Djava.class.path=<PATH TO JARFILE>
to the JVM's start parameters.
After the JVM has been started, the setup register_log_fn
function should be called:
tracing_slf4j::register_log_fn(&mut env).unwrap();
This function will register the Rust logging handler with the JVM.
Dependencies
~2–13MB
~96K SLoC