Add glog dependency.

This commit is contained in:
2023-03-11 21:15:15 -08:00
parent eba362a7f2
commit cb8b00f8d1
3 changed files with 325 additions and 21 deletions

View File

@@ -3,6 +3,7 @@ extern crate rocket;
use std::{error::Error, io::Cursor, str::FromStr};
use glog::Flags;
use notmuch::{Notmuch, NotmuchError, SearchSummary, ThreadSet};
use rocket::{
http::{ContentType, Header},
@@ -39,6 +40,7 @@ async fn search(
) -> Result<Json<shared::SearchResult>, Debug<NotmuchError>> {
let page = page.unwrap_or(0);
let results_per_page = results_per_page.unwrap_or(10);
info!(" search '{query}'");
let res = shared::SearchResult {
summary: nm.search(query, page * results_per_page, results_per_page)?,
query: query.to_string(),
@@ -120,6 +122,14 @@ async fn original(
#[rocket::main]
async fn main() -> Result<(), Box<dyn Error>> {
glog::new()
.init(Flags {
colorlogtostderr: true,
//alsologtostderr: true, // use logtostderr to only write to stderr and not to files
logtostderr: true,
..Default::default()
})
.unwrap();
let allowed_origins = AllowedOrigins::all();
let cors = rocket_cors::CorsOptions {
allowed_origins,