Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward Java log configuration to Rust log subscriber #2

Merged
merged 14 commits into from
Jul 7, 2023

Conversation

CarlAmko
Copy link
Contributor

@CarlAmko CarlAmko commented Jun 30, 2023

Resolves https://github.com/ngrok-private/ngrok/issues/16140

What

  • Configured logging level will now be used to filter log output from native Rust code.

How

  • Log level configuration is loaded by Rust linker middleware and passed to tracing_subscriber.

Validation

Default logging configured with TRACE:

...
[Thread-1] TRACE com.ngrok.Runtime - [muxado::session] sending frame to remote
[main] TRACE com.ngrok.Runtime - [log] calling unchecked jni method: ExceptionCheck
[main] TRACE com.ngrok.Runtime - [log] looking up jni method ExceptionCheck
[main] TRACE com.ngrok.Runtime - [log] found jni method
[Thread-1] TRACE com.ngrok.Runtime - [tokio_util::codec::framed_impl] flushing framed transport
[main] TRACE com.ngrok.Runtime - [log] no exception found
[main] TRACE com.ngrok.Runtime - [log] calling checked jni method: GetMethodID
[main] TRACE com.ngrok.Runtime - [log] looking up jni method GetMethodID
[Thread-1] TRACE com.ngrok.Runtime - [tokio_util::codec::framed_impl] writing;
[main] TRACE com.ngrok.Runtime - [log] found jni method
[main] TRACE com.ngrok.Runtime - [log] checking for exception
[Thread-1] TRACE com.ngrok.Runtime - [tokio_util::codec::framed_impl] framed transport flushed
[main] TRACE com.ngrok.Runtime - [log] calling unchecked jni method: ExceptionCheck
[main] TRACE com.ngrok.Runtime - [log] looking up jni method ExceptionCheck
[Thread-1] TRACE com.ngrok.Runtime - [muxado::session] sending frame to remote
[main] TRACE com.ngrok.Runtime - [log] found jni method
[Thread-1] TRACE com.ngrok.Runtime - [tokio_util::codec::framed_impl] flushing framed transport
[Thread-1] TRACE com.ngrok.Runtime - [tokio_util::codec::framed_impl] writing;
...

Configured with DEBUG:

...
[main] DEBUG com.ngrok.Runtime - [log] add_parsable_certificates processed 1 valid and 0 invalid certs
[main] DEBUG com.ngrok.Runtime - [log] No cached session for DnsName(DnsName(DnsName("tunnel.ngrok.com")))
[main] DEBUG com.ngrok.Runtime - [log] Not resuming any session
[main] DEBUG com.ngrok.Runtime - [log] Using ciphersuite TLS13_AES_128_GCM_SHA256
[main] DEBUG com.ngrok.Runtime - [log] Not resuming
[main] DEBUG com.ngrok.Runtime - [log] TLS1.3 encrypted extensions: []
[main] DEBUG com.ngrok.Runtime - [log] ALPN protocol is None
[main] DEBUG com.ngrok.Runtime - [log] Ticket saved
[Thread-0] DEBUG com.ngrok.Runtime - [muxado::heartbeat] sending heartbeat
[Thread-0] DEBUG com.ngrok.Runtime - [muxado::heartbeat] waiting for response
[main] DEBUG com.ngrok.Runtime - [ngrok::internals::raw_session] decoded rpc response
[Thread-1] DEBUG com.ngrok.Runtime - [muxado::heartbeat] got response
[Thread-0] DEBUG com.ngrok.Runtime - [muxado::stream_manager] got none from stream, trying to send a fin
[Thread-0] DEBUG com.ngrok.Runtime - [muxado::stream_manager] removing stream and sending fin
[Thread-1] DEBUG com.ngrok.Runtime - [muxado::typed] read stream type
[main] DEBUG com.ngrok.Runtime - [ngrok::internals::raw_session] decoded rpc response
[Thread-2] DEBUG com.ngrok.Runtime - [muxado::stream_manager] got none from stream, trying to send a fin
[Thread-2] DEBUG com.ngrok.Runtime - [muxado::stream_manager] removing stream and sending fin
[main] DEBUG com.ngrok.Runtime - [ngrok::internals::raw_session] decoded rpc response
[Thread-2] DEBUG com.ngrok.Runtime - [muxado::stream_manager] got none from stream, trying to send a fin
[Thread-2] DEBUG com.ngrok.Runtime - [muxado::stream_manager] removing stream and sending fin
[Thread-1] DEBUG com.ngrok.Runtime - [ngrok::internals::raw_session] decoded rpc error response
[Thread-1] DEBUG com.ngrok.Runtime - [muxado::session] write_task exited
[Thread-2] DEBUG com.ngrok.Runtime - [muxado::heartbeat] requester exited
[Thread-0] DEBUG com.ngrok.Runtime - [muxado::heartbeat] heartbeat responder exiting
[Thread-3] DEBUG com.ngrok.Runtime - [muxado::heartbeat] check exited
[main] DEBUG com.ngrok.Runtime - [log] add_parsable_certificates processed 1 valid and 0 invalid certs
[main] DEBUG com.ngrok.Runtime - [log] No cached session for DnsName(DnsName(DnsName("tunnel.ngrok.com")))
[main] DEBUG com.ngrok.Runtime - [log] Not resuming any session
[main] DEBUG com.ngrok.Runtime - [log] Using ciphersuite TLS13_AES_128_GCM_SHA256
[main] DEBUG com.ngrok.Runtime - [log] Not resuming
[main] DEBUG com.ngrok.Runtime - [log] TLS1.3 encrypted extensions: []
[main] DEBUG com.ngrok.Runtime - [log] ALPN protocol is None
[main] DEBUG com.ngrok.Runtime - [log] Ticket saved
[Thread-4] DEBUG com.ngrok.Runtime - [muxado::heartbeat] sending heartbeat
[Thread-4] DEBUG com.ngrok.Runtime - [muxado::heartbeat] waiting for response
[Thread-0] DEBUG com.ngrok.Runtime - [muxado::heartbeat] got response
[main] DEBUG com.ngrok.Runtime - [ngrok::internals::raw_session] decoded rpc response
[Thread-0] DEBUG com.ngrok.Runtime - [muxado::stream_manager] got none from stream, trying to send a fin
[Thread-0] DEBUG com.ngrok.Runtime - [muxado::stream_manager] removing stream and sending fin
[Thread-2] DEBUG com.ngrok.Runtime - [muxado::typed] read stream type
[Thread-0] DEBUG com.ngrok.Runtime - [muxado::session] write_task exited
[Thread-4] DEBUG com.ngrok.Runtime - [muxado::heartbeat] heartbeat responder exiting
[Thread-2] DEBUG com.ngrok.Runtime - [muxado::heartbeat] check exited
[Thread-1] DEBUG com.ngrok.Runtime - [muxado::heartbeat] requester exited
...

Configured with INFO:

[main] INFO com.ngrok.Runtime - [session] https://38fe-73-169-116-49.ngrok.io

@CarlAmko CarlAmko requested review from nikolay-ngrok and removed request for nikolay-ngrok June 30, 2023 15:01
@CarlAmko CarlAmko marked this pull request as ready for review June 30, 2023 16:07
ngrok-java-native/src/main/java/com/ngrok/Runtime.java Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
ngrok-java-native/src/lib.rs Outdated Show resolved Hide resolved
ngrok-java-native/src/main/java/com/ngrok/Runtime.java Outdated Show resolved Hide resolved
Copy link
Collaborator

@nikolay-ngrok nikolay-ngrok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks pretty close, few stylistic comments

ngrok-java-native/src/lib.rs Outdated Show resolved Hide resolved
@CarlAmko CarlAmko merged commit 0bc474d into main Jul 7, 2023
4 checks passed
@CarlAmko CarlAmko deleted the carl/log-filter branch July 12, 2023 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants