ui/dist
server/target
docker/dev/volumes
+docker/federation-test/volumes
.git
ports:
- "127.0.0.1:8536:8536"
restart: always
+ environment:
+ - RUST_LOG=debug
volumes:
- ./lemmy.hjson:/config/config.hjson:ro
depends_on:
image: mwader/postfix-relay
environment:
- POSTFIX_myhostname={{ domain }}
- restart: "always"
\ No newline at end of file
+ restart: "always"
ports:
- "127.0.0.1:8536:8536"
restart: always
+ environment:
+ - RUST_LOG=debug
volumes:
- ../lemmy.hjson:/config/config.hjson:ro
depends_on:
ports:
- "127.0.0.1:8536:8536"
restart: always
+ environment:
+ - RUST_LOG=debug
volumes:
- ./lemmy.hjson:/config/config.hjson:ro
depends_on:
while [ "$init_db_valid" == 0 ]
do
read -p "Initialize database (y/n)? " init_db
- case "${init_db,,}" in
+ case "${init_db,,}" in
y|yes ) init_db_valid=1; init_db_final=1;;
n|no ) init_db_valid=1; init_db_final=0;;
* ) echo "Invalid input" 1>&2;;
# Build and run the backend
cd ../server
-cargo run
+RUST_LOG=debug cargo run
# For live coding, where both the front and back end, automagically reload on any save, do:
# cd ui && yarn start
use crate::send_email;
use crate::settings::Settings;
use diesel::PgConnection;
+use log::error;
use std::str::FromStr;
#[derive(Serialize, Deserialize)]
// Let the uniqueness handle this fail
match UserMention::create(&conn, &user_mention_form) {
Ok(_mention) => (),
- Err(_e) => eprintln!("{}", &_e),
+ Err(_e) => error!("{}", &_e),
};
// Send an email to those users that have notifications on
);
match send_email(subject, &mention_email, &mention_user.name, html) {
Ok(_o) => _o,
- Err(e) => eprintln!("{}", e),
+ Err(e) => error!("{}", e),
};
}
}
);
match send_email(subject, &comment_reply_email, &parent_user.name, html) {
Ok(_o) => _o,
- Err(e) => eprintln!("{}", e),
+ Err(e) => error!("{}", e),
};
}
}
);
match send_email(subject, &post_reply_email, &parent_user.name, html) {
Ok(_o) => _o,
- Err(e) => eprintln!("{}", e),
+ Err(e) => error!("{}", e),
};
}
}
// Let the uniqueness handle this fail
match UserMention::create(&conn, &user_mention_form) {
Ok(_mention) => (),
- Err(_e) => eprintln!("{}", &_e),
+ Err(_e) => error!("{}", &_e),
}
}
}
use crate::{generate_random_string, send_email};
use bcrypt::verify;
use diesel::PgConnection;
+use log::error;
use std::str::FromStr;
#[derive(Serialize, Deserialize, Debug)]
);
match send_email(subject, &email, &recipient_user.name, html) {
Ok(_o) => _o,
- Err(e) => eprintln!("{}", e),
+ Err(e) => error!("{}", e),
};
}
}
use lettre::smtp::ConnectionReuseParameters;
use lettre::{ClientSecurity, SmtpClient, Transport};
use lettre_email::Email;
+use log::error;
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
Some(url) => match fetch_iframely(&url) {
Ok(res) => (res.title, res.description, res.thumbnail_url, res.html),
Err(e) => {
- eprintln!("iframely err: {}", e);
+ error!("iframely err: {}", e);
(None, None, None, None)
}
},
Some(iframely_thumbnail_url) => match fetch_pictshare(&iframely_thumbnail_url) {
Ok(res) => Some(res.url),
Err(e) => {
- eprintln!("pictshare err: {}", e);
+ error!("pictshare err: {}", e);
None
}
},
use actix_web::web;
use actix_web::*;
use actix_web_actors::ws;
+use log::{error, info};
use std::time::{Duration, Instant};
pub fn config(cfg: &mut web::ServiceConfig) {
type Result = ();
fn handle(&mut self, msg: WSMessage, ctx: &mut Self::Context) {
- // println!("id: {} msg: {}", self.id, msg.0);
ctx.text(msg.0);
}
}
/// WebSocket message handler
impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for WSSession {
fn handle(&mut self, result: Result<ws::Message, ws::ProtocolError>, ctx: &mut Self::Context) {
- // println!("WEBSOCKET MESSAGE: {:?} from id: {}", msg, self.id);
let message = match result {
Ok(m) => m,
Err(e) => {
- println!("{}", e);
+ error!("{}", e);
return;
}
};
}
ws::Message::Text(text) => {
let m = text.trim().to_owned();
- println!("WEBSOCKET MESSAGE: {:?} from id: {}", &m, self.id);
+ info!("Message received: {:?} from id: {}", &m, self.id);
self
.cs_addr
match res {
Ok(res) => ctx.text(res),
Err(e) => {
- eprintln!("{}", &e);
+ error!("{}", &e);
}
}
actix::fut::ready(())
})
.wait(ctx);
}
- ws::Message::Binary(_bin) => println!("Unexpected binary"),
+ ws::Message::Binary(_bin) => info!("Unexpected binary"),
ws::Message::Close(_) => {
ctx.stop();
}
// check client heartbeats
if Instant::now().duration_since(act.hb) > CLIENT_TIMEOUT {
// heartbeat timed out
- println!("Websocket Client heartbeat failed, disconnecting!");
+ error!("Websocket Client heartbeat failed, disconnecting!");
// notify chat server
act.cs_addr.do_send(Disconnect {
use diesel::r2d2::{ConnectionManager, Pool, PooledConnection};
use diesel::PgConnection;
use failure::Error;
-use log::warn;
+use log::{error, info, warn};
use rand::{rngs::ThreadRng, Rng};
use serde::{Deserialize, Serialize};
use serde_json::Value;
}
if rate_limit.allowance < 1.0 {
- println!(
+ warn!(
"Rate limited IP: {}, time_passed: {}, allowance: {}",
&info.ip, time_passed, rate_limit.allowance
);
fn handle(&mut self, msg: Connect, _ctx: &mut Context<Self>) -> Self::Result {
// register session with random id
let id = self.rng.gen::<usize>();
- println!("{} joined", &msg.ip);
+ info!("{} joined", &msg.ip);
self.sessions.insert(
id,
fn handle(&mut self, msg: StandardMessage, _: &mut Context<Self>) -> Self::Result {
match parse_json_message(self, msg) {
Ok(m) => {
- println!("Message Sent: {}", m);
+ info!("Message Sent: {}", m);
MessageResult(m)
}
Err(e) => {
- warn!("Error during message handling {}", e);
+ error!("Error during message handling {}", e);
MessageResult(e.to_string())
}
}