use logger instead of print
This commit is contained in:
parent
d75e3704e4
commit
a1f1ee51d0
4 changed files with 8 additions and 11 deletions
|
@ -45,7 +45,7 @@ impl<'r> FromRequest<'r> for DnsClient {
|
|||
let config = try_outcome!(request.guard::<&State<Config>>().await);
|
||||
match DnsClient::new(config.dns.server).await {
|
||||
Err(e) => {
|
||||
println!("Failed to connect to DNS server: {}", e);
|
||||
error!("Failed to connect to DNS server: {}", e);
|
||||
Outcome::Failure((Status::InternalServerError, ()))
|
||||
},
|
||||
Ok(c) => Outcome::Success(c)
|
||||
|
@ -60,7 +60,7 @@ impl<'r> FromRequest<'r> for Box<dyn RecordConnector> {
|
|||
let config = try_outcome!(request.guard::<&State<Config>>().await);
|
||||
match DnsClient::new(config.dns.server).await {
|
||||
Err(e) => {
|
||||
println!("Failed to connect to DNS server: {}", e);
|
||||
error!("Failed to connect to DNS server: {}", e);
|
||||
Outcome::Failure((Status::InternalServerError, ()))
|
||||
},
|
||||
Ok(c) => Outcome::Success(Box::new(DnsConnectorClient::new(c)))
|
||||
|
@ -75,7 +75,7 @@ impl<'r> FromRequest<'r> for Box<dyn ZoneConnector> {
|
|||
let config = try_outcome!(request.guard::<&State<Config>>().await);
|
||||
match DnsClient::new(config.dns.server).await {
|
||||
Err(e) => {
|
||||
println!("Failed to connect to DNS server: {}", e);
|
||||
error!("Failed to connect to DNS server: {}", e);
|
||||
Outcome::Failure((Status::InternalServerError, ()))
|
||||
},
|
||||
Ok(c) => Outcome::Success(Box::new(DnsConnectorClient::new(c)))
|
||||
|
|
|
@ -54,7 +54,7 @@ impl std::fmt::Display for DnsConnectorError {
|
|||
write!(f, "DNS client error: {}", e)
|
||||
},
|
||||
DnsConnectorError::ResponceNotOk { code, zone } => {
|
||||
write!(f, "Query for zone {} failed with code {}", zone, code)
|
||||
write!(f, "Query for zone \"{}\" failed with code \"{}\"", zone, code)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,6 @@ pub struct DbConn(diesel::SqliteConnection);
|
|||
|
||||
#[launch]
|
||||
async fn rocket() -> _ {
|
||||
//let app_config = config::load("config.toml".into());
|
||||
//println!("{:#?}", app_config);
|
||||
|
||||
|
||||
let figment = Figment::from(rocket::Config::default())
|
||||
.merge(Toml::file(Env::var_or("NOMILO_CONFIG", "nomilo.toml")).nested())
|
||||
.merge(Env::prefixed("NOMILO_").ignore(&["PROFILE"]).global())
|
||||
|
@ -41,7 +37,6 @@ async fn rocket() -> _ {
|
|||
exit(1);
|
||||
}
|
||||
};
|
||||
//let app_config = .expect("unable to load configuration");
|
||||
|
||||
rocket::custom(figment)
|
||||
.manage(app_config)
|
||||
|
|
|
@ -102,10 +102,11 @@ impl From<UserError> for ErrorResponse {
|
|||
|
||||
impl From<Box<dyn ConnectorError>> for ErrorResponse {
|
||||
fn from(e: Box<dyn ConnectorError>) -> Self {
|
||||
println!("{}", e);
|
||||
if e.is_proto_error() {
|
||||
error!("{}", e);
|
||||
return make_500(e);
|
||||
} else {
|
||||
warn!("{}", e);
|
||||
let error = ErrorResponse::new(
|
||||
Status::NotFound,
|
||||
"Zone could not be found".into()
|
||||
|
@ -168,6 +169,7 @@ impl From<ErrorResponse> for (Status, ErrorResponse) {
|
|||
|
||||
// TODO: change for Display trait
|
||||
pub fn make_500<E: std::fmt::Debug>(e: E) -> ErrorResponse {
|
||||
println!("Making 500 for Error: {:?}", e);
|
||||
error!("Making 500 for Error: {:?}", e);
|
||||
|
||||
ErrorResponse::new(Status::InternalServerError, "An unexpected error occured.".into())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue