summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjetil Orbekk <kjetil.orbekk@gmail.com>2020-02-01 09:13:12 -0500
committerKjetil Orbekk <kjetil.orbekk@gmail.com>2020-02-01 09:13:12 -0500
commitaa12104e4c5572a5806bf1e6b8dd27d72705ab84 (patch)
tree6f2f9344d1f139800350784c28d8a5eb6b62b4d8
parentfb9f143f2353dc8c64a18be84c12b53cdad847e7 (diff)
Improve logging legibility
-rw-r--r--src/importer.rs9
-rw-r--r--src/main.rs20
-rw-r--r--src/server.rs4
3 files changed, 22 insertions, 11 deletions
diff --git a/src/importer.rs b/src/importer.rs
index 8513b54..2966449 100644
--- a/src/importer.rs
+++ b/src/importer.rs
@@ -14,13 +14,11 @@ pub enum Command {
Quit,
}
-fn handle_command(pool: ThreadPool,
- command: Command) {
+fn handle_command(pool: ThreadPool, command: Command) {
info!("handle {:?}", command);
}
-fn receive_commands(pool: ThreadPool,
- rx: Arc<Mutex<Receiver<Command>>>) {
+fn receive_commands(pool: ThreadPool, rx: Arc<Mutex<Receiver<Command>>>) {
info!("receive_commands");
match (move || -> Result<(), Box<dyn std::error::Error>> {
let rx = rx.lock().expect("channel");
@@ -30,7 +28,8 @@ fn receive_commands(pool: ThreadPool,
let pool0 = pool.clone();
pool.execute(|| handle_command(pool0, command));
command = rx.recv()?;
- }})() {
+ }
+ })() {
Ok(()) => (),
Err(e) => {
error!("receive_commands: {:?}", e);
diff --git a/src/main.rs b/src/main.rs
index 7ced591..235c71f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -20,15 +20,25 @@ fn setup_logger() -> Result<(), fern::InitError> {
let thread_id = &format!("{:?}", thread.id())[..];
let prefix = "ThreadId(";
let thread_id = if thread_id.find(prefix).is_some() {
- &thread_id[prefix.len() .. thread_id.len() - 1]
+ &thread_id[prefix.len()..thread_id.len() - 1]
} else {
thread_id
};
- let thread_colors = [Color::Red, Color::Green, Color::Magenta,
- Color::Cyan, Color::White, Color::BrightRed,
- Color::BrightGreen, Color::BrightMagenta,
- Color::BrightWhite];
+ let thread_colors = [
+ Color::Red,
+ Color::Green,
+ Color::Magenta,
+ Color::Cyan,
+ Color::White,
+ Color::Yellow,
+ Color::BrightRed,
+ Color::BrightGreen,
+ Color::BrightMagenta,
+ Color::BrightCyan,
+ Color::BrightBlue,
+ Color::BrightWhite,
+ ];
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
let mut hasher = DefaultHasher::new();
diff --git a/src/server.rs b/src/server.rs
index c5a59f5..ad163e1 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -169,7 +169,9 @@ pub fn start(conn: diesel::PgConnection, db_url: &str, base_url: &str) {
let importer_pool = ThreadPool::with_name("import".to_string(), importer::WORKERS);
let tx = importer::run(importer_pool.clone());
- tx.send(importer::Command::Quit).expect("send");
+ for i in 0..100 {
+ tx.send(importer::Command::Quit).expect("send");
+ }
rocket::custom(config)
.manage(params)