mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-26 18:36:28 +00:00
add support for multiple log formats (#517)
this commit adds the tracing-subscriber crate and use its formatters to support multiple log formats. More details in https://github.com/postgresml/pgcat/issues/464#issuecomment-1641430299 Signed-off-by: Sebastian Webber <sebastian@swebber.me>
This commit is contained in:
19
src/main.rs
19
src/main.rs
@@ -61,18 +61,31 @@ use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::broadcast;
|
||||
|
||||
use pgcat::cmd_args;
|
||||
use pgcat::cmd_args::LogFormat;
|
||||
use pgcat::config::{get_config, reload_config, VERSION};
|
||||
use pgcat::dns_cache;
|
||||
use pgcat::messages::configure_socket;
|
||||
use pgcat::pool::{ClientServerMap, ConnectionPool};
|
||||
use pgcat::prometheus::start_metric_server;
|
||||
use pgcat::stats::{Collector, Reporter, REPORTER};
|
||||
|
||||
mod cmd_args;
|
||||
use tracing_subscriber;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let args = cmd_args::parse();
|
||||
pgcat::multi_logger::MultiLogger::init(args.log_level).unwrap();
|
||||
match args.log_format {
|
||||
LogFormat::Structured => tracing_subscriber::fmt()
|
||||
.json()
|
||||
.with_max_level(args.log_level)
|
||||
.init(),
|
||||
LogFormat::Debug => tracing_subscriber::fmt()
|
||||
.pretty()
|
||||
.with_max_level(args.log_level)
|
||||
.init(),
|
||||
_ => tracing_subscriber::fmt()
|
||||
.with_max_level(args.log_level)
|
||||
.init(),
|
||||
};
|
||||
|
||||
info!("Welcome to PgCat! Meow. (Version {})", VERSION);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user