Skip to content

Commit 3b83e97

Browse files
authored
Merge branch 'master' into feat/275a
2 parents 6505840 + bc5ad6e commit 3b83e97

File tree

9 files changed

+64
-35
lines changed

9 files changed

+64
-35
lines changed

db-tests/Cargo.lock

Lines changed: 16 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

db-tests/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ edition = "2018"
66

77
[dependencies]
88
codegen = { version = "0.1.0", path = "../codegen" }
9-
env_logger = "0.6.1"
9+
env_logger = "0.7.0"
1010
futures-preview = { git = "https://github.com/rust-lang-nursery/futures-rs", rev = "744ece9", features = ["compat"] }
11-
lazy_static = "1.3.0"
12-
rand = "0.6.5"
11+
lazy_static = "1.4.0"
12+
log="0.4"
13+
rand = "0.7.2"
1314
syncstorage = { version = "0.1.0", path = "../", features = ["db_test"] }
1415

db-tests/src/batch.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use futures::compat::Future01CompatExt;
22

33
use codegen::async_test;
4+
use log::debug;
5+
46
use syncstorage::{
57
db::{error::DbErrorKind, params, util::SyncTimestamp, BATCH_LIFETIME},
68
error::ApiErrorKind,
@@ -141,7 +143,7 @@ async fn append_commit() -> Result<()> {
141143
.compat()
142144
.await?;
143145

144-
dbg!("result", &result);
146+
debug!("result: {:?}", &result);
145147
assert!(result.success.contains(&"b0".to_owned()));
146148
assert!(result.success.contains(&"b2".to_owned()));
147149

src/db/spanner/models.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use futures::future;
22
use futures::lazy;
33

44
use diesel::r2d2::PooledConnection;
5+
use log::debug;
56

67
use std::cell::RefCell;
78
use std::collections::HashMap;
@@ -439,7 +440,10 @@ impl SpannerDb {
439440
&self,
440441
params: params::GetCollectionTimestamp,
441442
) -> Result<SyncTimestamp> {
442-
dbg!("!!QQQ get_collection_timestamp_sync", &params.collection);
443+
debug!(
444+
"!!QQQ get_collection_timestamp_sync {:?}",
445+
&params.collection
446+
);
443447

444448
let collection_id = self.get_collection_id(&params.collection)?;
445449
if let Some(modified) = self
@@ -1005,7 +1009,7 @@ impl SpannerDb {
10051009
}
10061010

10071011
pub fn get_bso_timestamp_sync(&self, params: params::GetBsoTimestamp) -> Result<SyncTimestamp> {
1008-
dbg!("!!QQQ get_bso_timestamp_sync", &params.collection);
1012+
debug!("!!QQQ get_bso_timestamp_sync: {:?}", &params.collection);
10091013
let collection_id = self.get_collection_id(&params.collection)?;
10101014

10111015
let result = self
@@ -1099,7 +1103,7 @@ impl SpannerDb {
10991103
}
11001104

11011105
if !inserts.is_empty() {
1102-
dbg!(&inserts);
1106+
debug!("inserts: {:?}", &inserts);
11031107
self.insert(
11041108
"bso",
11051109
&[
@@ -1116,7 +1120,7 @@ impl SpannerDb {
11161120
);
11171121
}
11181122
for (columns, values) in updates {
1119-
dbg!(&columns, &values);
1123+
debug!("columns: {:?}, values:{:?}", &columns, &values);
11201124
self.update("bso", &columns, values);
11211125
}
11221126

@@ -1266,7 +1270,10 @@ impl SpannerDb {
12661270
.map_or(i64::from(DEFAULT_BSO_TTL), |ttl| ttl.try_into().unwrap())
12671271
* 1000;
12681272
let expirystring = to_rfc3339(now_millis + ttl)?;
1269-
dbg!("!!!!! INSERT", &expirystring, timestamp, ttl);
1273+
debug!(
1274+
"!!!!! INSERT expirystring:{:?}, timestamp:{:?}, ttl:{:?}",
1275+
&expirystring, timestamp, ttl
1276+
);
12701277
sqlparams.insert("expiry".to_string(), as_value(expirystring));
12711278
sqltypes.insert("expiry".to_string(), SpannerType::Timestamp.into());
12721279

src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use std::error::Error;
33

44
use docopt::Docopt;
5-
use log::info;
5+
use log::{debug, info};
66
use serde_derive::Deserialize;
77

88
use syncstorage::{logging, server, settings};
@@ -22,6 +22,7 @@ struct Args {
2222

2323
fn main() -> Result<(), Box<dyn Error>> {
2424
env_logger::init();
25+
debug!("Starting up...");
2526
// Set SENTRY_DSN environment variable to enable Sentry
2627
let sentry = sentry::init(sentry::ClientOptions::default());
2728
if sentry.is_enabled() {

src/server/metrics.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::net::UdpSocket;
22

33
use actix_web::{error::ErrorInternalServerError, Error, HttpRequest};
44
use cadence::{BufferedUdpMetricSink, Counted, NopMetricSink, QueuingMetricSink, StatsdClient};
5+
use log::debug;
56

67
use crate::error::ApiError;
78
use crate::server::ServerState;
@@ -18,7 +19,7 @@ impl From<&HttpRequest> for Metrics {
1819
client: match req.app_data::<ServerState>() {
1920
Some(v) => Some(*v.metrics.clone()),
2021
None => {
21-
dbg!("⚠️ metric error: No App State");
22+
debug!("⚠️ metric error: No App State");
2223
None
2324
}
2425
},
@@ -45,7 +46,7 @@ impl Metrics {
4546
match self.client.unwrap().incr(label) {
4647
Err(e) => {
4748
// eat the metric, but log the error
48-
dbg!("⚠️ Metric {} error: {:?} ", label, e);
49+
debug!("⚠️ Metric {} error: {:?} ", label, e);
4950
}
5051
Ok(_v) => {
5152
// v.as_metric_str()
@@ -79,7 +80,7 @@ pub fn metrics_from_opts(opts: &Settings) -> Result<StatsdClient, ApiError> {
7980
};
8081
Ok(builder
8182
.with_error_handler(|err| {
82-
dbg!("⚠️ Metric send error:", err);
83+
debug!("⚠️ Metric send error: {:?}", err);
8384
})
8485
.build())
8586
}

src/settings.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Application settings objects and initialization
22
33
use config::{Config, ConfigError, Environment, File};
4+
use log::debug;
45
use serde::{de::Deserializer, Deserialize, Serialize};
56
use url::Url;
67

@@ -118,11 +119,11 @@ impl Settings {
118119
"For example to set `database_url` use env var `{}_DATABASE_URL`\n",
119120
PREFIX.to_uppercase()
120121
);
121-
dbg!("⚠️ Configuration error: Value undefined", &v);
122+
debug!("⚠️ Configuration error: Value undefined {:?}", &v);
122123
return Err(ConfigError::NotFound(v));
123124
}
124125
_ => {
125-
dbg!("⚠️ Other: ", &e);
126+
debug!("⚠️ Other: {:?}", &e);
126127
return Err(e);
127128
}
128129
},

src/web/extractors.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use actix_web::{
1616
};
1717
use futures::{future, Future};
1818
use lazy_static::lazy_static;
19+
use log::debug;
1920
use regex::Regex;
2021
use serde::{
2122
de::{Deserializer, Error as SerdeError, IgnoredAny},
@@ -120,7 +121,7 @@ impl FromRequest for BsoBodies {
120121
let default = HeaderValue::from_static("");
121122
let content_type = get_trimmed_header(headers, CONTENT_TYPE, &default);
122123

123-
dbg!(&content_type);
124+
debug!("content_type: {:?}", &content_type);
124125

125126
match content_type.as_str() {
126127
"application/json" | "text/plain" | "application/newlines" | "" => (),
@@ -138,7 +139,7 @@ impl FromRequest for BsoBodies {
138139

139140
// Load the entire request into a String
140141
let fut = <String>::from_request(req, payload).map_err(|e| {
141-
dbg!("⚠️ Payload read error", e);
142+
debug!("⚠️ Payload read error: {:?}", e);
142143
ValidationErrorKind::FromDetails(
143144
"Mimetype/encoding/content-length error".to_owned(),
144145
RequestErrorLocation::Header,
@@ -165,7 +166,7 @@ impl FromRequest for BsoBodies {
165166
let state = match req.app_data::<ServerState>() {
166167
Some(s) => s,
167168
None => {
168-
dbg!("⚠️ Could not load the app state");
169+
debug!("⚠️ Could not load the app state");
169170
return Box::new(future::err(
170171
ValidationErrorKind::FromDetails(
171172
"Internal error".to_owned(),
@@ -315,7 +316,7 @@ impl FromRequest for BsoBody {
315316
let state = match req.app_data::<ServerState>() {
316317
Some(s) => s,
317318
None => {
318-
dbg!("⚠️ Could not load the app state");
319+
debug!("⚠️ Could not load the app state");
319320
return Box::new(future::err(
320321
ValidationErrorKind::FromDetails(
321322
"Internal error".to_owned(),
@@ -391,7 +392,7 @@ impl BsoParam {
391392
}
392393
if let Some(v) = elements.get(5) {
393394
let sv = String::from_str(v).map_err(|e| {
394-
dbg!("⚠️ BsoParam Error", v, e);
395+
debug!("⚠️ BsoParam Error element:{:?} error:{:?}", v, e);
395396
ValidationErrorKind::FromDetails(
396397
"Invalid BSO".to_owned(),
397398
RequestErrorLocation::Path,
@@ -615,7 +616,7 @@ impl FromRequest for CollectionPostRequest {
615616
let state = match req.app_data::<ServerState>() {
616617
Some(s) => s,
617618
None => {
618-
dbg!("⚠️ Could not load the app state");
619+
debug!("⚠️ Could not load the app state");
619620
return Box::new(future::err(
620621
ValidationErrorKind::FromDetails(
621622
"Internal error".to_owned(),
@@ -798,7 +799,7 @@ impl FromRequest for ConfigRequest {
798799
let state = match req.app_data::<ServerState>() {
799800
Some(s) => s,
800801
None => {
801-
dbg!("⚠️ Could not load the app state");
802+
debug!("⚠️ Could not load the app state");
802803
return Err(ValidationErrorKind::FromDetails(
803804
"Internal error".to_owned(),
804805
RequestErrorLocation::Unknown,
@@ -859,7 +860,7 @@ impl HawkIdentifier {
859860
let elements: Vec<&str> = uri.path().split('/').collect();
860861
if let Some(v) = elements.get(2) {
861862
u64::from_str(v).map_err(|e| {
862-
dbg!("⚠️ HawkIdentifier Error", v, e);
863+
debug!("⚠️ HawkIdentifier Error {:?} {:?}", v, e);
863864
ValidationErrorKind::FromDetails(
864865
"Invalid UID".to_owned(),
865866
RequestErrorLocation::Path,
@@ -936,7 +937,7 @@ impl FromRequest for HawkIdentifier {
936937
let state = match req.app_data::<ServerState>() {
937938
Some(s) => s,
938939
None => {
939-
dbg!("⚠️ Could not load the app state");
940+
debug!("⚠️ Could not load the app state");
940941
return Err(ValidationErrorKind::FromDetails(
941942
"Internal error".to_owned(),
942943
RequestErrorLocation::Unknown,
@@ -964,7 +965,7 @@ impl From<u32> for HawkIdentifier {
964965

965966
pub fn extrude_db(exts: &Extensions) -> Result<Box<dyn Db>, Error> {
966967
exts.get::<Box<dyn Db>>().cloned().ok_or_else(|| {
967-
dbg!("⚠️ DB Error: No db");
968+
debug!("⚠️ DB Error: No db");
968969
ErrorInternalServerError("Unexpected Db error: No DB".to_owned())
969970
})
970971
}
@@ -1074,7 +1075,7 @@ impl FromRequest for BatchRequestOpt {
10741075
let state = match req.app_data::<ServerState>() {
10751076
Some(s) => s,
10761077
None => {
1077-
dbg!("⚠️ Could not load the app state");
1078+
debug!("⚠️ Could not load the app state");
10781079
return Err(ValidationErrorKind::FromDetails(
10791080
"Internal error".to_owned(),
10801081
RequestErrorLocation::Unknown,

src/web/middleware.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use futures::{
1818
future::{self, Either, FutureResult},
1919
Future, Poll,
2020
};
21+
use log::debug;
2122

2223
use crate::db::{params, util::SyncTimestamp};
2324
use crate::error::{ApiError, ApiErrorKind};
@@ -200,7 +201,7 @@ where
200201
Err(e) => {
201202
// Semi-example to show how to use metrics inside of middleware.
202203
metrics::Metrics::from(&state).incr("sync.error.collectionParam");
203-
dbg!("⚠️ CollectionParam err: {:?}", e);
204+
debug!("⚠️ CollectionParam err: {:?}", e);
204205
return Box::new(future::ok(
205206
sreq.into_response(
206207
HttpResponse::InternalServerError()
@@ -215,7 +216,7 @@ where
215216
let hawk_user_id = match sreq.get_hawk_id() {
216217
Ok(v) => v,
217218
Err(e) => {
218-
dbg!("⚠️ Bad Hawk Id: ", e);
219+
debug!("⚠️ Bad Hawk Id: {:?}", e);
219220
return Box::new(future::ok(
220221
sreq.into_response(
221222
HttpResponse::Unauthorized()
@@ -331,7 +332,7 @@ where
331332
None => PreConditionHeader::NoHeader,
332333
},
333334
Err(e) => {
334-
dbg!("⚠️ Precondition error", e);
335+
debug!("⚠️ Precondition error {:?}", e);
335336
return Box::new(future::ok(
336337
sreq.into_response(
337338
HttpResponse::BadRequest()
@@ -345,7 +346,7 @@ where
345346
let user_id = match sreq.get_hawk_id() {
346347
Ok(v) => v,
347348
Err(e) => {
348-
dbg!("⚠️ Hawk header error", e);
349+
debug!("⚠️ Hawk header error {:?}", e);
349350
return Box::new(future::ok(
350351
sreq.into_response(
351352
HttpResponse::Unauthorized()
@@ -360,7 +361,7 @@ where
360361
let db = match edb {
361362
Ok(v) => v,
362363
Err(e) => {
363-
dbg!("⚠️ Database access error", e);
364+
debug!("⚠️ Database access error {:?}", e);
364365
return Box::new(future::ok(
365366
sreq.into_response(
366367
HttpResponse::InternalServerError()
@@ -376,7 +377,7 @@ where
376377
let collection = match col_result {
377378
Ok(v) => v.map(|c| c.collection),
378379
Err(e) => {
379-
dbg!("⚠️ Collection Error: ", e);
380+
debug!("⚠️ Collection Error: {:?}", e);
380381
return Box::new(future::ok(
381382
sreq.into_response(
382383
HttpResponse::InternalServerError()
@@ -431,7 +432,7 @@ where
431432
if let Ok(ts_header) =
432433
header::HeaderValue::from_str(&resource_ts.as_header())
433434
{
434-
dbg!(format!("📝 Setting X-Last-Modfied {:?}", ts_header));
435+
debug!("📝 Setting X-Last-Modfied {:?}", ts_header);
435436
resp.headers_mut().insert(
436437
header::HeaderName::from_static(X_LAST_MODIFIED),
437438
ts_header,

0 commit comments

Comments
 (0)