Log with tracing-subscriber (#399)
* chore: log examples with tracing-subscriber * chore: log [issues] with tracing-subscriber * chore: log [cli] with tracing-subscriber * feat: tracing will emit log if tracing-subscriber is not setup
This commit is contained in:
parent
695fa57f4e
commit
2d5aa2a61b
@ -27,7 +27,7 @@ async-trait = { version = "^0.1" }
|
|||||||
chrono = { version = "^0", optional = true }
|
chrono = { version = "^0", optional = true }
|
||||||
futures = { version = "^0.3" }
|
futures = { version = "^0.3" }
|
||||||
futures-util = { version = "^0.3" }
|
futures-util = { version = "^0.3" }
|
||||||
tracing = "0.1"
|
tracing = { version = "0.1", features = ["log"] }
|
||||||
rust_decimal = { version = "^1", optional = true }
|
rust_decimal = { version = "^1", optional = true }
|
||||||
sea-orm-macros = { version = "^0.4.2", path = "sea-orm-macros", optional = true }
|
sea-orm-macros = { version = "^0.4.2", path = "sea-orm-macros", optional = true }
|
||||||
sea-query = { version = "^0.20.0", features = ["thread-safe"] }
|
sea-query = { version = "^0.20.0", features = ["thread-safe"] }
|
||||||
|
@ -18,12 +18,12 @@ tera = "1.8.0"
|
|||||||
dotenv = "0.15"
|
dotenv = "0.15"
|
||||||
listenfd = "0.3.3"
|
listenfd = "0.3.3"
|
||||||
serde = "1"
|
serde = "1"
|
||||||
env_logger = "0.8"
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||||
|
|
||||||
[dependencies.sea-orm]
|
[dependencies.sea-orm]
|
||||||
path = "../../" # remove this line in your own project
|
path = "../../" # remove this line in your own project
|
||||||
version = "^0.4.0"
|
version = "^0.4.0"
|
||||||
features = ["macros", "runtime-actix-native-tls"]
|
features = ["macros", "runtime-actix-native-tls", "debug-print"]
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -155,7 +155,7 @@ async fn delete(data: web::Data<AppState>, id: web::Path<i32>) -> Result<HttpRes
|
|||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
std::env::set_var("RUST_LOG", "debug");
|
std::env::set_var("RUST_LOG", "debug");
|
||||||
env_logger::init();
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
// get env vars
|
// get env vars
|
||||||
dotenv::dotenv().ok();
|
dotenv::dotenv().ok();
|
||||||
|
@ -18,12 +18,12 @@ tera = "1.8.0"
|
|||||||
dotenv = "0.15"
|
dotenv = "0.15"
|
||||||
listenfd = "0.3.3"
|
listenfd = "0.3.3"
|
||||||
serde = "1"
|
serde = "1"
|
||||||
env_logger = "0.8"
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||||
|
|
||||||
[dependencies.sea-orm]
|
[dependencies.sea-orm]
|
||||||
path = "../../" # remove this line in your own project
|
path = "../../" # remove this line in your own project
|
||||||
version = "^0.4.0"
|
version = "^0.4.0"
|
||||||
features = ["macros", "runtime-async-std-native-tls"]
|
features = ["macros", "runtime-async-std-native-tls", "debug-print"]
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -181,7 +181,7 @@ async fn delete(
|
|||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
std::env::set_var("RUST_LOG", "debug");
|
std::env::set_var("RUST_LOG", "debug");
|
||||||
env_logger::init();
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
// get env vars
|
// get env vars
|
||||||
dotenv::dotenv().ok();
|
dotenv::dotenv().ok();
|
||||||
|
@ -16,15 +16,15 @@ tower-http = { version = "0.2", features = ["fs"] }
|
|||||||
tower-cookies = { version = "0.4" }
|
tower-cookies = { version = "0.4" }
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
dotenv = "0.15"
|
dotenv = "0.15"
|
||||||
env_logger = "0.9"
|
|
||||||
serde = "1"
|
serde = "1"
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
tera = "1"
|
tera = "1"
|
||||||
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||||
|
|
||||||
[dependencies.sea-orm]
|
[dependencies.sea-orm]
|
||||||
path = "../../" # remove this line in your own project
|
path = "../../" # remove this line in your own project
|
||||||
version = "^0.4.2"
|
version = "^0.4.2"
|
||||||
features = ["macros", "runtime-tokio-native-tls"]
|
features = ["macros", "runtime-tokio-native-tls", "debug-print"]
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -23,7 +23,7 @@ use tower_http::services::ServeDir;
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> anyhow::Result<()> {
|
||||||
env::set_var("RUST_LOG", "debug");
|
env::set_var("RUST_LOG", "debug");
|
||||||
env_logger::init();
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
dotenv::dotenv().ok();
|
dotenv::dotenv().ok();
|
||||||
let db_url = env::var("DATABASE_URL").expect("DATABASE_URL is not set in .env file");
|
let db_url = env::var("DATABASE_URL").expect("DATABASE_URL is not set in .env file");
|
||||||
|
@ -10,5 +10,5 @@ publish = false
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
sea-orm = { path = "../../", features = [ "sqlx-all", "runtime-tokio-native-tls", "debug-print" ] }
|
sea-orm = { path = "../../", features = [ "sqlx-all", "runtime-tokio-native-tls", "debug-print" ] }
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
env_logger = { version = "^0.9" }
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||||
log = { version = "^0.4" }
|
tracing = { version = "0.1" }
|
||||||
|
@ -3,9 +3,9 @@ use sea_orm::*;
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
pub async fn main() {
|
pub async fn main() {
|
||||||
env_logger::builder()
|
tracing_subscriber::fmt()
|
||||||
.filter_level(log::LevelFilter::Debug)
|
.with_max_level(tracing::Level::DEBUG)
|
||||||
.is_test(true)
|
.with_test_writer()
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
let db = Database::connect("mysql://sea:sea@localhost/bakery")
|
let db = Database::connect("mysql://sea:sea@localhost/bakery")
|
||||||
|
@ -30,8 +30,8 @@ sea-schema = { version = "0.3.0", default-features = false, features = [
|
|||||||
"writer",
|
"writer",
|
||||||
] }
|
] }
|
||||||
sqlx = { version = "^0.5", default-features = false, features = [ "mysql", "postgres" ] }
|
sqlx = { version = "^0.5", default-features = false, features = [ "mysql", "postgres" ] }
|
||||||
env_logger = { version = "^0.9" }
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||||
log = { version = "^0.4" }
|
tracing = { version = "0.1" }
|
||||||
url = "^2.2"
|
url = "^2.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
use dotenv::dotenv;
|
use dotenv::dotenv;
|
||||||
use log::LevelFilter;
|
|
||||||
use sea_orm_codegen::{EntityTransformer, OutputFile, WithSerde};
|
use sea_orm_codegen::{EntityTransformer, OutputFile, WithSerde};
|
||||||
use std::{error::Error, fmt::Display, fs, io::Write, path::Path, process::Command, str::FromStr};
|
use std::{error::Error, fmt::Display, fs, io::Write, path::Path, process::Command, str::FromStr};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
@ -33,9 +32,9 @@ async fn run_generate_command(matches: &ArgMatches<'_>) -> Result<(), Box<dyn Er
|
|||||||
let expanded_format = args.is_present("EXPANDED_FORMAT");
|
let expanded_format = args.is_present("EXPANDED_FORMAT");
|
||||||
let with_serde = args.value_of("WITH_SERDE").unwrap();
|
let with_serde = args.value_of("WITH_SERDE").unwrap();
|
||||||
if args.is_present("VERBOSE") {
|
if args.is_present("VERBOSE") {
|
||||||
let _ = ::env_logger::builder()
|
let _ = tracing_subscriber::fmt()
|
||||||
.filter_level(LevelFilter::Debug)
|
.with_max_level(tracing::Level::DEBUG)
|
||||||
.is_test(true)
|
.with_test_writer()
|
||||||
.try_init();
|
.try_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user