Hotfix to correct typo and set default log level to `warn`

This commit is contained in:
Daniel Sockwell 2019-07-09 20:13:37 -04:00
parent a67317b0a2
commit 00cf62cd09
4 changed files with 22 additions and 11 deletions

View File

@ -1,6 +1,11 @@
# Uncomment any of the variables below to customize your enviornment
#SERVER_ADDR=
#REDIS_ADDR=
#POSTGRES_ADDR=
CORS_ALLOWED_METHODS="GET OPTIONS"
#REDIS_ADDR=
#SERVER_ADDR=
#SSE_UPDATE_INTERVAL=
#WS_UPDATE_INTERVAL=
#REDIS_POLL_INTERVAL=
#Possible values for the log level are eror, warn, info, debug, trace
RUST_LOG=warn

View File

@ -18,14 +18,19 @@ const DEFAULT_WS_UPDATE_INTERVAL: u64 = 100;
const DEFAULT_REDIS_POLL_INTERVAL: u64 = 100;
lazy_static! {
static ref POSTGRES_ADDR: String = env::var("POSTGRESS_ADDR").unwrap_or_else(|_| {
static ref POSTGRES_ADDR: String = env::var("POSTGRES_ADDR").unwrap_or_else(|_| {
let mut postgres_addr = DEFAULT_POSTGRES_ADDR.to_string();
postgres_addr.insert_str(11,
&env::var("USER").unwrap_or_else(|_| {
warn!("No USER env variable set. Connecting to Postgress with default `postgres` user");
"postgres".to_string()
}).as_str()
);
match &env::var("USER") {
Err(_) => {
warn!("No USER env variable set. Connecting to Postgress with default `postgres` user");
"postgres"
},
Ok(user) => {
warn!("No POSTGRES_ADDR env variable set. Connecting to Postgress with the current user: {}", &user);
user
}
});
postgres_addr
});
@ -64,8 +69,8 @@ pub fn cross_origin_resource_sharing() -> warp::filters::cors::Cors {
/// Initialize logging and read values from `src/.env`
pub fn logging_and_env() {
pretty_env_logger::init();
dotenv().ok();
pretty_env_logger::init();
}
/// Configure Postgres and return a connection

View File

@ -3,6 +3,7 @@ use crate::config;
pub fn query_for_user_data(access_token: &str) -> (i64, Option<Vec<String>>, Vec<String>) {
let conn = config::postgres();
let query_result = conn
.query(
"

View File

@ -1,5 +1,5 @@
//! Provides an interface between the `Warp` filters and the underlying
//! mechanics of talking with Redis/managing multiple threads.
//! mechanics of talking with Redis/managing multiple threads.
//!
//! The `ClientAgent`'s interface is very simple. All you can do with it is:
//! * Create a totally new `ClientAgent` with no shared data;