Replace println!()s with logging macros
This commit is contained in:
parent
ee96d2b754
commit
becb40544c
@ -1,5 +1,6 @@
|
|||||||
use activitypub::{Activity, Link, Object};
|
use activitypub::{Activity, Link, Object};
|
||||||
use array_tool::vec::Uniq;
|
use array_tool::vec::Uniq;
|
||||||
|
use tracing::{debug, warn};
|
||||||
use reqwest::r#async::ClientBuilder;
|
use reqwest::r#async::ClientBuilder;
|
||||||
use rocket::{
|
use rocket::{
|
||||||
http::Status,
|
http::Status,
|
||||||
@ -153,10 +154,10 @@ where
|
|||||||
.send()
|
.send()
|
||||||
.and_then(|r| r.into_body().concat2())
|
.and_then(|r| r.into_body().concat2())
|
||||||
.map(move |response| {
|
.map(move |response| {
|
||||||
println!("Successfully sent activity to inbox ({})", inbox);
|
debug!("Successfully sent activity to inbox ({})", inbox);
|
||||||
println!("Response: \"{:?}\"\n", response)
|
debug!("Response: \"{:?}\"\n", response)
|
||||||
})
|
})
|
||||||
.map_err(|e| println!("Error while sending to inbox ({:?})", e)),
|
.map_err(|e| warn!("Error while sending to inbox ({:?})", e)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
rt.run().unwrap();
|
rt.run().unwrap();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use crate::{Connection, Error, Result};
|
use crate::{Connection, Error, Result};
|
||||||
use diesel::connection::{Connection as Conn, SimpleConnection};
|
use diesel::connection::{Connection as Conn, SimpleConnection};
|
||||||
|
use tracing::info;
|
||||||
use migrations_internals::{setup_database, MigrationConnection};
|
use migrations_internals::{setup_database, MigrationConnection};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ struct ComplexMigration {
|
|||||||
|
|
||||||
impl ComplexMigration {
|
impl ComplexMigration {
|
||||||
fn run(&self, conn: &Connection, path: &Path) -> Result<()> {
|
fn run(&self, conn: &Connection, path: &Path) -> Result<()> {
|
||||||
println!("Running migration {}", self.name);
|
info!("Running migration {}", self.name);
|
||||||
for step in self.up {
|
for step in self.up {
|
||||||
step.run(conn, path)?
|
step.run(conn, path)?
|
||||||
}
|
}
|
||||||
@ -34,7 +35,7 @@ impl ComplexMigration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn revert(&self, conn: &Connection, path: &Path) -> Result<()> {
|
fn revert(&self, conn: &Connection, path: &Path) -> Result<()> {
|
||||||
println!("Reverting migration {}", self.name);
|
info!("Reverting migration {}", self.name);
|
||||||
for step in self.down {
|
for step in self.down {
|
||||||
step.run(conn, path)?
|
step.run(conn, path)?
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use tracing::warn;
|
||||||
use plume_common::activity_pub::{
|
use plume_common::activity_pub::{
|
||||||
inbox::FromId,
|
inbox::FromId,
|
||||||
request::Digest,
|
request::Digest,
|
||||||
@ -41,7 +42,7 @@ pub fn handle_incoming(
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map_err(|_| {
|
.map_err(|_| {
|
||||||
println!(
|
warn!(
|
||||||
"Rejected invalid activity supposedly from {}, with headers {:?}",
|
"Rejected invalid activity supposedly from {}, with headers {:?}",
|
||||||
actor.username, headers.0
|
actor.username, headers.0
|
||||||
);
|
);
|
||||||
@ -58,7 +59,7 @@ pub fn handle_incoming(
|
|||||||
Ok(match inbox(&rockets, act) {
|
Ok(match inbox(&rockets, act) {
|
||||||
Ok(_) => String::new(),
|
Ok(_) => String::new(),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Shared inbox error: {:?}", e);
|
warn!("Shared inbox error: {:?}", e);
|
||||||
format!("Error: {:?}", e)
|
format!("Error: {:?}", e)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -13,6 +13,7 @@ extern crate validator_derive;
|
|||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use clap::App;
|
use clap::App;
|
||||||
use diesel::r2d2::ConnectionManager;
|
use diesel::r2d2::ConnectionManager;
|
||||||
|
use tracing::warn;
|
||||||
use plume_models::{
|
use plume_models::{
|
||||||
db_conn::{DbPool, PragmaForeignKey},
|
db_conn::{DbPool, PragmaForeignKey},
|
||||||
instance::Instance,
|
instance::Instance,
|
||||||
@ -114,7 +115,7 @@ Then try to restart Plume.
|
|||||||
.expect("main: error on backing up search index directory for recreating");
|
.expect("main: error on backing up search index directory for recreating");
|
||||||
if UnmanagedSearcher::create(&CONFIG.search_index, &CONFIG.search_tokenizers).is_ok() {
|
if UnmanagedSearcher::create(&CONFIG.search_index, &CONFIG.search_tokenizers).is_ok() {
|
||||||
if fs::remove_dir_all(backup_path).is_err() {
|
if fs::remove_dir_all(backup_path).is_err() {
|
||||||
eprintln!(
|
warn!(
|
||||||
"error on removing backup directory: {}. it remains",
|
"error on removing backup directory: {}. it remains",
|
||||||
backup_path.display()
|
backup_path.display()
|
||||||
);
|
);
|
||||||
@ -173,8 +174,8 @@ Then try to restart Plume
|
|||||||
|
|
||||||
let mail = mail::init();
|
let mail = mail::init();
|
||||||
if mail.is_none() && CONFIG.rocket.as_ref().unwrap().environment.is_prod() {
|
if mail.is_none() && CONFIG.rocket.as_ref().unwrap().environment.is_prod() {
|
||||||
println!("Warning: the email server is not configured (or not completely).");
|
warn!("Warning: the email server is not configured (or not completely).");
|
||||||
println!("Please refer to the documentation to see how to configure it.");
|
warn!("Please refer to the documentation to see how to configure it.");
|
||||||
}
|
}
|
||||||
|
|
||||||
let rocket = rocket
|
let rocket = rocket
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use crate::template_utils::{IntoContext, Ructe};
|
use crate::template_utils::{IntoContext, Ructe};
|
||||||
|
use tracing::warn;
|
||||||
use plume_models::{Error, PlumeRocket};
|
use plume_models::{Error, PlumeRocket};
|
||||||
use rocket::{
|
use rocket::{
|
||||||
response::{self, Responder},
|
response::{self, Responder},
|
||||||
@ -49,7 +50,7 @@ pub fn server_error(req: &Request<'_>) -> Ructe {
|
|||||||
#[post("/csrf-violation?<target>")]
|
#[post("/csrf-violation?<target>")]
|
||||||
pub fn csrf_violation(target: Option<String>, rockets: PlumeRocket) -> Ructe {
|
pub fn csrf_violation(target: Option<String>, rockets: PlumeRocket) -> Ructe {
|
||||||
if let Some(uri) = target {
|
if let Some(uri) = target {
|
||||||
eprintln!("Csrf violation while accessing \"{}\"", uri)
|
warn!("Csrf violation while accessing \"{}\"", uri)
|
||||||
}
|
}
|
||||||
render!(errors::csrf(&rockets.to_context()))
|
render!(errors::csrf(&rockets.to_context()))
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use crate::routes::RespondOrRedirect;
|
use crate::routes::RespondOrRedirect;
|
||||||
use lettre::Transport;
|
use lettre::Transport;
|
||||||
|
use tracing::warn;
|
||||||
use rocket::http::ext::IntoOwned;
|
use rocket::http::ext::IntoOwned;
|
||||||
use rocket::{
|
use rocket::{
|
||||||
http::{uri::Uri, Cookie, Cookies, SameSite},
|
http::{uri::Uri, Cookie, Cookies, SameSite},
|
||||||
@ -155,7 +156,7 @@ pub fn password_reset_request(
|
|||||||
) {
|
) {
|
||||||
if let Some(ref mut mail) = *mail.lock().unwrap() {
|
if let Some(ref mut mail) = *mail.lock().unwrap() {
|
||||||
mail.send(message.into())
|
mail.send(message.into())
|
||||||
.map_err(|_| eprintln!("Couldn't send password reset email"))
|
.map_err(|_| warn!("Couldn't send password reset email"))
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ use activitypub::{
|
|||||||
collection::{OrderedCollection, OrderedCollectionPage},
|
collection::{OrderedCollection, OrderedCollectionPage},
|
||||||
};
|
};
|
||||||
use diesel::SaveChangesDsl;
|
use diesel::SaveChangesDsl;
|
||||||
|
use tracing::{info, warn};
|
||||||
use rocket::{
|
use rocket::{
|
||||||
http::{ContentType, Cookies},
|
http::{ContentType, Cookies},
|
||||||
request::LenientForm,
|
request::LenientForm,
|
||||||
@ -67,9 +68,9 @@ pub fn details(
|
|||||||
Ok(article) => {
|
Ok(article) => {
|
||||||
Post::from_activity(&fetch_rockets, article)
|
Post::from_activity(&fetch_rockets, article)
|
||||||
.expect("Article from remote user couldn't be saved");
|
.expect("Article from remote user couldn't be saved");
|
||||||
println!("Fetched article from remote user");
|
info!("Fetched article from remote user");
|
||||||
}
|
}
|
||||||
Err(e) => println!("Error while fetching articles in background: {:?}", e),
|
Err(e) => warn!("Error while fetching articles in background: {:?}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user