Skip to content

Commit c5f74e7

Browse files
committed
Use prefixed log macros
1 parent e77da88 commit c5f74e7

File tree

29 files changed

+195
-224
lines changed

29 files changed

+195
-224
lines changed

components/places/examples/autocomplete.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use clap::value_t;
66
use failure::bail;
7-
use log::*;
87
use places::{VisitObservation, VisitTransition};
98
use serde_derive::*;
109
use sql_support::ConnExt;
@@ -157,7 +156,7 @@ fn import_places(
157156
(ps, vs)
158157
};
159158

160-
info!(
159+
log::info!(
161160
"Importing {} visits across {} places!",
162161
place_count, visit_count
163162
);
@@ -231,7 +230,7 @@ fn import_places(
231230
println!("Finished processing records");
232231
println!("Committing....");
233232
tx.commit()?;
234-
info!("Finished import!");
233+
log::info!("Finished import!");
235234
Ok(())
236235
}
237236

@@ -345,7 +344,7 @@ mod autocomplete {
345344
}
346345
Err(e) => {
347346
// TODO: this is likely not to go very well since we're in raw mode...
348-
error!("Got error doing autocomplete: {:?}", e);
347+
log::error!("Got error doing autocomplete: {:?}", e);
349348
panic!("Got error doing autocomplete: {:?}", e);
350349
// return Err(e.into());
351350
}
@@ -808,14 +807,14 @@ fn main() -> Result<()> {
808807
.unwrap_or(0.1),
809808
};
810809
let import_source = if import_places_arg == "auto" {
811-
info!("Automatically locating largest places DB in your profile(s)");
810+
log::info!("Automatically locating largest places DB in your profile(s)");
812811
let profile_info = if let Some(info) = find_places_db::get_largest_places_db()? {
813812
info
814813
} else {
815-
error!("Failed to locate your firefox profile!");
814+
log::error!("Failed to locate your firefox profile!");
816815
bail!("--import-places=auto specified, but couldn't find a `places.sqlite`");
817816
};
818-
info!(
817+
log::info!(
819818
"Using a {} places.sqlite from profile '{}' (places path = {:?})",
820819
profile_info.friendly_db_size(),
821820
profile_info.profile_name,
@@ -848,17 +847,17 @@ fn main() -> Result<()> {
848847
}
849848

850849
if let Some(observations_json) = matches.value_of("import_observations") {
851-
info!("Importing observations from {}", observations_json);
850+
log::info!("Importing observations from {}", observations_json);
852851
let observations: Vec<SerializedObservation> = read_json_file(observations_json)?;
853852
let num_observations = observations.len();
854-
info!("Found {} observations", num_observations);
853+
log::info!("Found {} observations", num_observations);
855854
let mut counter = 0;
856855
for obs in observations {
857856
let visit = obs.into_visit()?;
858857
places::apply_observation(&mut conn, visit)?;
859858
counter += 1;
860859
if (counter % 1000) == 0 {
861-
trace!("Importing observations {} / {}", counter, num_observations);
860+
log::trace!("Importing observations {} / {}", counter, num_observations);
862861
}
863862
}
864863
}

components/places/examples/sync_history.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use failure::Fail;
66
use fxa_client::{AccessTokenInfo, Config, FirefoxAccount};
7-
use log::*;
87
use places::history_sync::store::HistoryStore;
98
use places::PlacesDb;
109
use std::{fs, io::Read};
@@ -87,7 +86,7 @@ fn main() -> Result<()> {
8786
.expect("Encryption key is not optional");
8887

8988
// Lets not log the encryption key, it's just not a good habit to be in.
90-
debug!(
89+
log::debug!(
9190
"Using credential file = {:?}, db = {:?}",
9291
cred_file, db_path
9392
);
@@ -117,22 +116,22 @@ fn main() -> Result<()> {
117116
let store = HistoryStore::new(&db);
118117

119118
if matches.is_present("wipe-remote") {
120-
info!("Wiping remote");
119+
log::info!("Wiping remote");
121120
let client = Sync15StorageClient::new(client_init.clone())?;
122121
client.wipe_all_remote()?;
123122
}
124123

125124
if matches.is_present("reset") {
126-
info!("Resetting");
125+
log::info!("Resetting");
127126
store.reset()?;
128127
}
129128

130-
info!("Syncing!");
129+
log::info!("Syncing!");
131130
if let Err(e) = store.sync(&client_init, &root_sync_key) {
132-
warn!("Sync failed! {}", e);
133-
warn!("BT: {:?}", e.backtrace());
131+
log::warn!("Sync failed! {}", e);
132+
log::warn!("BT: {:?}", e.backtrace());
134133
} else {
135-
info!("Sync was successful!");
134+
log::info!("Sync was successful!");
136135
}
137136
println!("Exiting (bye!)");
138137
Ok(())

components/places/ffi/src/lib.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use ffi_support::{
66
call_with_result, define_box_destructor, define_string_destructor, rust_str_from_c,
77
rust_string_from_c, ExternError,
88
};
9-
use log::*;
109
use places::history_sync::store::HistoryStore;
1110
use places::{storage, PlacesDb};
1211
use std::os::raw::c_char;
@@ -25,7 +24,7 @@ fn logging_init() {
2524
android_logger::Filter::default().with_min_level(log::Level::Trace),
2625
Some("libplaces_ffi"),
2726
);
28-
debug!("Android logging should be hooked up!")
27+
log::debug!("Android logging should be hooked up!")
2928
}
3029
}
3130

@@ -40,7 +39,7 @@ pub unsafe extern "C" fn places_connection_new(
4039
encryption_key: *const c_char,
4140
error: &mut ExternError,
4241
) -> *mut PlacesDb {
43-
trace!("places_connection_new");
42+
log::trace!("places_connection_new");
4443
logging_init();
4544
call_with_result(error, || {
4645
let path = ffi_support::rust_string_from_c(db_path);
@@ -57,7 +56,7 @@ pub unsafe extern "C" fn places_note_observation(
5756
json_observation: *const c_char,
5857
error: &mut ExternError,
5958
) {
60-
trace!("places_note_observation");
59+
log::trace!("places_note_observation");
6160
call_with_result(error, || {
6261
let json = ffi_support::rust_str_from_c(json_observation);
6362
let visit: places::VisitObservation = serde_json::from_str(&json)?;
@@ -74,7 +73,7 @@ pub unsafe extern "C" fn places_query_autocomplete(
7473
limit: u32,
7574
error: &mut ExternError,
7675
) -> *mut c_char {
77-
trace!("places_query_autocomplete");
76+
log::trace!("places_query_autocomplete");
7877
call_with_result(error, || {
7978
search_frecent(
8079
conn,
@@ -92,7 +91,7 @@ pub unsafe extern "C" fn places_get_visited(
9291
urls_json: *const c_char,
9392
error: &mut ExternError,
9493
) -> *mut c_char {
95-
trace!("places_get_visited");
94+
log::trace!("places_get_visited");
9695
// This function has a dumb amount of overhead and copying...
9796
call_with_result(error, || -> places::Result<String> {
9897
let json = ffi_support::rust_str_from_c(urls_json);
@@ -116,7 +115,7 @@ pub extern "C" fn places_get_visited_urls_in_range(
116115
include_remote: u8, // JNA has issues with bools...
117116
error: &mut ExternError,
118117
) -> *mut c_char {
119-
trace!("places_get_visited_in_range");
118+
log::trace!("places_get_visited_in_range");
120119
call_with_result(error, || -> places::Result<String> {
121120
let visited = storage::get_visited_urls(
122121
conn,
@@ -138,7 +137,7 @@ pub unsafe extern "C" fn sync15_history_sync(
138137
tokenserver_url: *const c_char,
139138
error: &mut ExternError,
140139
) {
141-
trace!("sync15_history_sync");
140+
log::trace!("sync15_history_sync");
142141
call_with_result(error, || -> places::Result<()> {
143142
// XXX - this is wrong - we kinda want this to be long-lived - the "Db"
144143
// should own the store, but it's not part of the db.

components/places/src/api/history.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use crate::db::PlacesDb;
77
use crate::error::*;
88
use crate::observation::VisitObservation;
99
use crate::types::*;
10-
use log::*;
1110
use url::Url;
1211

1312
// This module can become, roughly: PlacesUtils.history()
@@ -182,7 +181,7 @@ pub fn visit_uri(
182181
// EMBED visits are session-persistent and should not go through the database.
183182
// They exist only to keep track of isVisited status during the session.
184183
if transition == VisitTransition::Embed {
185-
warn!("Embed visit, but in-memory storage of these isn't done yet");
184+
log::warn!("Embed visit, but in-memory storage of these isn't done yet");
186185
return Ok(());
187186
}
188187

components/places/src/db/schema.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use crate::db::PlacesDb;
1111
use crate::error::*;
1212
use lazy_static::lazy_static;
13-
use log::*;
1413
use sql_support::ConnExt;
1514

1615
const VERSION: i64 = 2;
@@ -236,7 +235,7 @@ pub fn init(db: &PlacesDb) -> Result<()> {
236235
if user_version < VERSION {
237236
upgrade(db, user_version)?;
238237
} else {
239-
warn!(
238+
log::warn!(
240239
"Loaded future schema version {} (we only understand version {}). \
241240
Optimisitically ",
242241
user_version, VERSION
@@ -248,7 +247,7 @@ pub fn init(db: &PlacesDb) -> Result<()> {
248247

249248
// https://github.com/mozilla-mobile/firefox-ios/blob/master/Storage/SQL/LoginsSchema.swift#L100
250249
fn upgrade(_db: &PlacesDb, from: i64) -> Result<()> {
251-
debug!("Upgrading schema from {} to {}", from, VERSION);
250+
log::debug!("Upgrading schema from {} to {}", from, VERSION);
252251
if from == VERSION {
253252
return Ok(());
254253
}
@@ -258,7 +257,7 @@ fn upgrade(_db: &PlacesDb, from: i64) -> Result<()> {
258257
}
259258

260259
pub fn create(db: &PlacesDb) -> Result<()> {
261-
debug!("Creating schema");
260+
log::debug!("Creating schema");
262261
db.execute_all(&[
263262
CREATE_TABLE_PLACES_SQL,
264263
CREATE_TABLE_PLACES_TOMBSTONES_SQL,
@@ -283,7 +282,7 @@ pub fn create(db: &PlacesDb) -> Result<()> {
283282
&format!("PRAGMA user_version = {version}", version = VERSION),
284283
])?;
285284

286-
debug!("Creating temp tables and triggers");
285+
log::debug!("Creating temp tables and triggers");
287286
db.execute_all(&[
288287
CREATE_TRIGGER_AFTER_INSERT_ON_PLACES,
289288
&CREATE_TRIGGER_HISTORYVISITS_AFTERINSERT,

components/places/src/ffi.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use crate::error::{Error, ErrorKind};
1212
use ffi_support::{
1313
implement_into_ffi_by_json, implement_into_ffi_by_pointer, ErrorCode, ExternError,
1414
};
15-
use log::*;
1615

1716
pub mod error_codes {
1817
// Note: 0 (success) and -1 (panic) are reserved by ffi_support
@@ -36,23 +35,23 @@ pub mod error_codes {
3635
fn get_code(err: &Error) -> ErrorCode {
3736
match err.kind() {
3837
ErrorKind::InvalidPlaceInfo(info) => {
39-
error!("Invalid place info: {}", info);
38+
log::error!("Invalid place info: {}", info);
4039
ErrorCode::new(error_codes::INVALID_PLACE_INFO)
4140
}
4241
ErrorKind::UrlParseError(e) => {
43-
error!("URL parse error: {}", e);
42+
log::error!("URL parse error: {}", e);
4443
ErrorCode::new(error_codes::URL_PARSE_ERROR)
4544
}
4645
// Can't pattern match on `err` without adding a dep on the sqlite3-sys crate,
4746
// so we just use a `if` guard.
4847
ErrorKind::SqlError(rusqlite::Error::SqliteFailure(err, msg))
4948
if err.code == rusqlite::ErrorCode::DatabaseBusy =>
5049
{
51-
error!("Database busy: {:?} {:?}", err, msg);
50+
log::error!("Database busy: {:?} {:?}", err, msg);
5251
ErrorCode::new(error_codes::DATABASE_BUSY)
5352
}
5453
err => {
55-
error!("Unexpected error: {:?}", err);
54+
log::error!("Unexpected error: {:?}", err);
5655
ErrorCode::new(error_codes::UNEXPECTED)
5756
}
5857
}

components/places/src/history_sync/plan.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use crate::storage::history_sync::{
1212
};
1313
use crate::types::{SyncGuid, Timestamp, VisitTransition};
1414
use crate::valid_guid::is_valid_places_guid;
15-
use log::*;
1615
use rusqlite::Connection;
1716
use sql_support::ConnExt;
1817
use std::collections::HashSet;
@@ -184,7 +183,7 @@ pub fn apply_plan(conn: &Connection, inbound: IncomingChangeset) -> Result<Outgo
184183
Err(e) => {
185184
// We can't push IncomingPlan::Invalid into plans as we don't
186185
// know the guid - just skip it.
187-
warn!("Error deserializing incoming record: {}", e);
186+
log::warn!("Error deserializing incoming record: {}", e);
188187
continue;
189188
}
190189
};
@@ -205,19 +204,19 @@ pub fn apply_plan(conn: &Connection, inbound: IncomingChangeset) -> Result<Outgo
205204
for (guid, plan) in plans {
206205
match &plan {
207206
IncomingPlan::Skip => {
208-
trace!("incoming: skipping item {:?}", guid);
207+
log::trace!("incoming: skipping item {:?}", guid);
209208
}
210209
IncomingPlan::Invalid(err) => {
211-
warn!(
210+
log::warn!(
212211
"incoming: record {:?} skipped because it is invalid: {}",
213212
guid, err
214213
);
215214
}
216215
IncomingPlan::Failed(err) => {
217-
error!("incoming: record {:?} failed to apply: {}", guid, err);
216+
log::error!("incoming: record {:?} failed to apply: {}", guid, err);
218217
}
219218
IncomingPlan::Delete => {
220-
trace!("incoming: deleting {:?}", guid);
219+
log::trace!("incoming: deleting {:?}", guid);
221220
num_deleted += 1;
222221
apply_synced_deletion(&conn, &guid)?;
223222
}
@@ -228,7 +227,7 @@ pub fn apply_plan(conn: &Connection, inbound: IncomingChangeset) -> Result<Outgo
228227
visits,
229228
} => {
230229
num_applied += 1;
231-
trace!(
230+
log::trace!(
232231
"incoming: will apply {:?}: url={:?}, title={:?}, to_add={:?}",
233232
guid,
234233
url,
@@ -249,7 +248,7 @@ pub fn apply_plan(conn: &Connection, inbound: IncomingChangeset) -> Result<Outgo
249248
}
250249
IncomingPlan::Reconciled => {
251250
num_reconciled += 1;
252-
trace!("incoming: reconciled {:?}", guid);
251+
log::trace!("incoming: reconciled {:?}", guid);
253252
apply_synced_reconciliation(&conn, &guid)?;
254253
}
255254
};
@@ -263,12 +262,12 @@ pub fn apply_plan(conn: &Connection, inbound: IncomingChangeset) -> Result<Outgo
263262
OutgoingInfo::Record(record) => Payload::from_record(record)?,
264263
OutgoingInfo::Tombstone => Payload::new_tombstone_with_ttl(guid.0.clone(), HISTORY_TTL),
265264
};
266-
trace!("outgoing {:?}", payload);
265+
log::trace!("outgoing {:?}", payload);
267266
outgoing.changes.push(payload);
268267
}
269268
tx.commit()?;
270269

271-
info!(
270+
log::info!(
272271
"incoming: applied {}, deleted {}, reconciled {}",
273272
num_applied, num_deleted, num_reconciled
274273
);
@@ -279,7 +278,7 @@ pub fn apply_plan(conn: &Connection, inbound: IncomingChangeset) -> Result<Outgo
279278
pub fn finish_plan(conn: &Connection) -> Result<()> {
280279
let tx = conn.unchecked_transaction()?;
281280
finish_outgoing(conn)?;
282-
trace!("Committing final sync plan");
281+
log::trace!("Committing final sync plan");
283282
tx.commit()?;
284283
Ok(())
285284
}

0 commit comments

Comments
 (0)