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

Improve logging in fxa-client, and bump android_logger version #533

Merged
merged 1 commit into from Jan 10, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -2,6 +2,14 @@

**TODO: remove before tagging/publishing a release**

[Full Changelog](https://github.com/mozilla/application-services/compare/v0.13.1...master)

## Firefox Accounts

### What's New

- The fxa-client android library will now write logs to logcat. ([#533](https://github.com/mozilla/application-services/pull/533))

# 0.13.1 (_2019-01-10_)

[Full Changelog](https://github.com/mozilla/application-services/compare/v0.13.0...v0.13.1)

Some generated files are not rendered by default. Learn more.

@@ -10,10 +10,14 @@ crate-type = ["lib", "staticlib", "cdylib"]

[dependencies]
ffi-support = { path = "../../support/ffi" }
log = "0.4.6"

[dependencies.fxa-client]
path = "../"
features = ["ffi"]

[features]
browserid = ["fxa-client/browserid"]

[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.7.0"
@@ -9,6 +9,17 @@ use ffi_support::{
use fxa_client::{ffi::*, FirefoxAccount, PersistCallback};
use std::{ffi::CString, os::raw::c_char};

fn logging_init() {
#[cfg(target_os = "android")]
{
android_logger::init_once(
android_logger::Filter::default().with_min_level(log::Level::Trace),
Some("libfxaclient_ffi"),
);
log::debug!("Android logging should be hooked up!")
}
}

/// Creates a [FirefoxAccount] from credentials obtained with the onepw FxA login flow.
///
/// This is typically used by the legacy Sync clients: new clients mainly use OAuth flows and
@@ -28,6 +39,8 @@ pub unsafe extern "C" fn fxa_from_credentials(
err: &mut ExternError,
) -> *mut FirefoxAccount {
use fxa_client::WebChannelResponse;
logging_init();
log::trace!("fxa_from_credentials");
call_with_result(err, || {
let content_url = rust_str_from_c(content_url);
let client_id = rust_str_from_c(client_id);
@@ -51,6 +64,8 @@ pub unsafe extern "C" fn fxa_new(
redirect_uri: *const c_char,
err: &mut ExternError,
) -> *mut FirefoxAccount {
logging_init();
log::trace!("fxa_new");
call_with_output(err, || {
let content_url = rust_str_from_c(content_url);
let client_id = rust_str_from_c(client_id);
@@ -70,6 +85,8 @@ pub unsafe extern "C" fn fxa_from_json(
json: *const c_char,
err: &mut ExternError,
) -> *mut FirefoxAccount {
logging_init();
log::trace!("fxa_from_json");
call_with_result(err, || FirefoxAccount::from_json(rust_str_from_c(json)))
}

@@ -84,6 +101,7 @@ pub unsafe extern "C" fn fxa_from_json(
/// pointer type.
#[no_mangle]
pub extern "C" fn fxa_to_json(fxa: &mut FirefoxAccount, error: &mut ExternError) -> *mut c_char {
log::trace!("fxa_to_json");
call_with_result(error, || fxa.to_json())
}

@@ -95,6 +113,7 @@ pub unsafe extern "C" fn fxa_register_persist_callback(
callback: extern "C" fn(json: *const c_char),
error: &mut ExternError,
) {
log::trace!("fxa_register_persist_callback");
call_with_output(error, || {
fxa.register_persist_callback(PersistCallback::new(move |json| {
// It's impossible for JSON to have embedded null bytes.
@@ -110,6 +129,7 @@ pub extern "C" fn fxa_unregister_persist_callback(
fxa: &mut FirefoxAccount,
error: &mut ExternError,
) {
log::trace!("fxa_unregister_persist_callback");
call_with_output(error, || {
fxa.unregister_persist_callback();
});
@@ -130,6 +150,7 @@ pub extern "C" fn fxa_profile(
ignore_cache: bool,
error: &mut ExternError,
) -> *mut ProfileC {
log::trace!("fxa_profile");
call_with_result(error, || fxa.get_profile(ignore_cache))
}

@@ -144,6 +165,7 @@ pub extern "C" fn fxa_get_token_server_endpoint_url(
fxa: &FirefoxAccount,
error: &mut ExternError,
) -> *mut c_char {
log::trace!("fxa_get_token_server_endpoint_url");
call_with_result(error, || {
fxa.get_token_server_endpoint_url().map(|u| u.to_string())
})
@@ -160,6 +182,7 @@ pub extern "C" fn fxa_get_connection_success_url(
fxa: &FirefoxAccount,
error: &mut ExternError,
) -> *mut c_char {
log::trace!("fxa_get_connection_success_url");
call_with_result(error, || {
fxa.get_connection_success_url().map(|u| u.to_string())
})
@@ -179,6 +202,7 @@ pub unsafe extern "C" fn fxa_assertion_new(
audience: *const c_char,
error: &mut ExternError,
) -> *mut c_char {
log::trace!("fxa_assertion_new");
call_with_result(error, || {
let audience = rust_str_from_c(audience);
fxa.generate_assertion(audience)
@@ -198,6 +222,7 @@ pub extern "C" fn fxa_get_sync_keys(
fxa: &mut FirefoxAccount,
error: &mut ExternError,
) -> *mut SyncKeysC {
log::trace!("fxa_get_sync_keys");
call_with_result(error, || fxa.get_sync_keys())
}

@@ -218,6 +243,7 @@ pub unsafe extern "C" fn fxa_begin_pairing_flow(
scope: *const c_char,
error: &mut ExternError,
) -> *mut c_char {
log::trace!("fxa_begin_pairing_flow");
call_with_result(error, || {
let pairing_url = rust_str_from_c(pairing_url);
let scope = rust_str_from_c(scope);
@@ -247,6 +273,7 @@ pub unsafe extern "C" fn fxa_begin_oauth_flow(
wants_keys: bool,
error: &mut ExternError,
) -> *mut c_char {
log::trace!("fxa_begin_oauth_flow");
call_with_result(error, || {
let scope = rust_str_from_c(scope);
let scopes: Vec<&str> = scope.split(" ").collect();
@@ -267,6 +294,7 @@ pub unsafe extern "C" fn fxa_complete_oauth_flow(
state: *const c_char,
error: &mut ExternError,
) {
log::trace!("fxa_complete_oauth_flow");
call_with_result(error, || {
let code = rust_str_from_c(code);
let state = rust_str_from_c(state);
@@ -291,6 +319,7 @@ pub unsafe extern "C" fn fxa_get_access_token(
scope: *const c_char,
error: &mut ExternError,
) -> *mut AccessTokenInfoC {
log::trace!("fxa_get_access_token");
call_with_result(error, || {
let scope = rust_str_from_c(scope);
fxa.get_access_token(&scope)
@@ -174,6 +174,9 @@ macro_rules! impl_from_error {
impl From<$type> for ErrorKind {
#[inline]
fn from(e: $type) -> ErrorKind {
// We lose some information when boxing the wrapped errors, so
// log them here before that happens.
log::error!("FxA error `{}`: {:?}", stringify!($type), e);
ErrorKind::$variant(e)
}
}
@@ -29,4 +29,4 @@ path = "../../sync15"
path = "../../support/ffi"

[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.6.0"
android_logger = "0.7.0"
@@ -26,4 +26,4 @@ path = ".."
features = ["ffi"]

[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.6.0"
android_logger = "0.7.0"
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.