🚧 Code tweaks
This commit is contained in:
parent
5736b5d67b
commit
322cd9b6bf
6 changed files with 20 additions and 19 deletions
|
|
@ -7,17 +7,15 @@ edition = "2021"
|
||||||
# https://doc.rust-lang.org/cargo/reference/manifest.html
|
# https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Opcional. Para configurar servicios usando las macros de Actix Web:
|
# Si requiere acceso a base de datos (mysql, postgres y/o sqlite):
|
||||||
actix-web = "4"
|
pagetop = { version = "0.0", features = ["mysql"], default-features = false }
|
||||||
|
# pagetop = "0.0" (en otro caso)
|
||||||
|
|
||||||
# Opcional. Para usar archivos y recursos binarios contenidos en el ejecutable:
|
# Opcional. Para usar archivos y recursos binarios contenidos en el ejecutable:
|
||||||
static-files = "0.2.3"
|
static-files = "0.2.3"
|
||||||
# Opcional. Para serializar estructuras de datos:
|
# Opcional. Para serializar estructuras de datos:
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
|
||||||
# Si requiere acceso a base de datos (mysql, postgres y/o sqlite):
|
|
||||||
pagetop = { version = "0.0", features = ["mysql"], default-features = false }
|
|
||||||
# pagetop = "0.0" (en otro caso)
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
# Opcional. Para incluir archivos y recursos binarios en el ejecutable:
|
# Opcional. Para incluir archivos y recursos binarios en el ejecutable:
|
||||||
pagetop-build = "0.0"
|
pagetop-build = "0.0"
|
||||||
|
|
|
||||||
|
|
@ -7,15 +7,15 @@ edition = "2021"
|
||||||
# https://doc.rust-lang.org/cargo/reference/manifest.html
|
# https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
# Si requiere acceso a base de datos:
|
||||||
|
pagetop = { version = "0.0", features = ["database"], default-features = false }
|
||||||
|
# pagetop = "0.0" (en otro caso)
|
||||||
|
|
||||||
# Opcional. Para usar archivos y recursos binarios contenidos en la librería:
|
# Opcional. Para usar archivos y recursos binarios contenidos en la librería:
|
||||||
static-files = "0.2.3"
|
static-files = "0.2.3"
|
||||||
# Opcional. Para serializar estructuras de datos:
|
# Opcional. Para serializar estructuras de datos:
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
|
||||||
# Si requiere acceso a base de datos:
|
|
||||||
pagetop = { version = "0.0", features = ["database"], default-features = false }
|
|
||||||
# pagetop = "0.0" (en otro caso)
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
# Opcional. Para incluir archivos y recursos binarios en la propia librería:
|
# Opcional. Para incluir archivos y recursos binarios en la propia librería:
|
||||||
pagetop-build = "0.0"
|
pagetop-build = "0.0"
|
||||||
|
|
|
||||||
|
|
@ -59,13 +59,13 @@ impl Application {
|
||||||
// Registers package actions.
|
// Registers package actions.
|
||||||
package::all::register_actions();
|
package::all::register_actions();
|
||||||
|
|
||||||
// Initializes the packages.
|
|
||||||
package::all::init_packages();
|
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "database")]
|
||||||
// Runs pending database migrations.
|
// Runs pending database migrations.
|
||||||
package::all::run_migrations();
|
package::all::run_migrations();
|
||||||
|
|
||||||
|
// Initializes the packages.
|
||||||
|
package::all::init_packages();
|
||||||
|
|
||||||
Self
|
Self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,13 +35,13 @@ pub trait PackageTrait: AnyBase + Send + Sync {
|
||||||
actions![]
|
actions![]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init(&self) {}
|
|
||||||
|
|
||||||
#[cfg(feature = "database")]
|
#[cfg(feature = "database")]
|
||||||
fn migrations(&self) -> Vec<MigrationItem> {
|
fn migrations(&self) -> Vec<MigrationItem> {
|
||||||
migrations![]
|
migrations![]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn init(&self) {}
|
||||||
|
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
fn configure_service(&self, scfg: &mut service::web::ServiceConfig) {}
|
fn configure_service(&self, scfg: &mut service::web::ServiceConfig) {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,8 +92,8 @@ use crate::{config, kv, AutoDefault, LazyStatic, LOCALES_PAGETOP};
|
||||||
pub use fluent_templates;
|
pub use fluent_templates;
|
||||||
pub use unic_langid::LanguageIdentifier;
|
pub use unic_langid::LanguageIdentifier;
|
||||||
|
|
||||||
pub(crate) use fluent_templates::Loader;
|
use fluent_templates::Loader;
|
||||||
pub(crate) use fluent_templates::StaticLoader as Locales;
|
use fluent_templates::StaticLoader as Locales;
|
||||||
|
|
||||||
use unic_langid::langid;
|
use unic_langid::langid;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,10 +36,11 @@ use tracing_subscriber::EnvFilter;
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
pub(crate) static TRACING: LazyStatic<WorkerGuard> = LazyStatic::new(|| {
|
pub(crate) static TRACING: LazyStatic<WorkerGuard> = LazyStatic::new(|| {
|
||||||
let env_filter =
|
let env_filter = EnvFilter::try_new(&config::SETTINGS.log.tracing)
|
||||||
EnvFilter::try_new(&config::SETTINGS.log.tracing).unwrap_or_else(|_| EnvFilter::new("Info"));
|
.unwrap_or_else(|_| EnvFilter::new("Info"));
|
||||||
|
|
||||||
let rolling = config::SETTINGS.log.rolling.to_lowercase();
|
let rolling = config::SETTINGS.log.rolling.to_lowercase();
|
||||||
|
|
||||||
let (non_blocking, guard) = match rolling.as_str() {
|
let (non_blocking, guard) = match rolling.as_str() {
|
||||||
"stdout" => tracing_appender::non_blocking(std::io::stdout()),
|
"stdout" => tracing_appender::non_blocking(std::io::stdout()),
|
||||||
_ => tracing_appender::non_blocking({
|
_ => tracing_appender::non_blocking({
|
||||||
|
|
@ -60,10 +61,12 @@ pub(crate) static TRACING: LazyStatic<WorkerGuard> = LazyStatic::new(|| {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
let subscriber = tracing_subscriber::fmt()
|
let subscriber = tracing_subscriber::fmt()
|
||||||
.with_env_filter(env_filter)
|
.with_env_filter(env_filter)
|
||||||
.with_writer(non_blocking)
|
.with_writer(non_blocking)
|
||||||
.with_ansi(rolling.as_str() == "stdout");
|
.with_ansi(rolling.as_str() == "stdout");
|
||||||
|
|
||||||
match config::SETTINGS.log.format.to_lowercase().as_str() {
|
match config::SETTINGS.log.format.to_lowercase().as_str() {
|
||||||
"json" => subscriber.json().init(),
|
"json" => subscriber.json().init(),
|
||||||
"full" => subscriber.init(),
|
"full" => subscriber.init(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue