Add logging functionality to the dev panel
This commit is contained in:
parent
c8dd82a5e0
commit
812ba9dc3b
6 changed files with 141 additions and 38 deletions
|
|
@ -1,13 +1,14 @@
|
|||
use askama::Template;
|
||||
use axum::{
|
||||
body, debug_handler,
|
||||
extract::{Extension, Request, State},
|
||||
extract::{Extension, Query, Request, State},
|
||||
http::{StatusCode, header},
|
||||
middleware::Next,
|
||||
response::{Html, IntoResponse, Response},
|
||||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{Context, Result, consts, data::db, html_templates::*, ron_utils};
|
||||
use crate::{AppState, Context, Result, consts, data::db, html_templates::*, log::Log, ron_utils};
|
||||
|
||||
pub mod fragments;
|
||||
pub mod recipe;
|
||||
|
|
@ -62,10 +63,18 @@ pub async fn home_page(
|
|||
|
||||
///// DEV_PANEL /////
|
||||
|
||||
#[debug_handler]
|
||||
#[derive(Deserialize)]
|
||||
pub struct LogFile {
|
||||
#[serde(default)]
|
||||
pub log_file: String,
|
||||
}
|
||||
|
||||
#[debug_handler(state = AppState)]
|
||||
pub async fn dev_panel(
|
||||
State(connection): State<db::Connection>,
|
||||
State(log): State<Log>,
|
||||
Extension(context): Extension<Context>,
|
||||
log_file: Query<LogFile>,
|
||||
) -> Result<Response> {
|
||||
if context.user.is_some() && context.user.as_ref().unwrap().is_admin {
|
||||
Ok(Html(
|
||||
|
|
@ -73,6 +82,8 @@ pub async fn dev_panel(
|
|||
recipes: Recipes::new(connection, &context.user, context.tr.current_lang_code())
|
||||
.await?,
|
||||
context,
|
||||
log,
|
||||
current_log_file: log_file.log_file.clone(),
|
||||
}
|
||||
.render()?,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue