add --no-color option to disable colors in the terminal (#518)

add --no-color option to disable colors

this commit adds a new option to disable colors in the terminal and also
moves the logger configuration to a different crate.

Signed-off-by: Sebastian Webber <sebastian@swebber.me>
This commit is contained in:
Sebastian Webber
2023-07-20 01:15:55 -03:00
committed by GitHub
parent f85e5bd9e8
commit 19cb8a3022
4 changed files with 26 additions and 15 deletions

View File

@@ -62,30 +62,17 @@ 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::logger;
use pgcat::messages::configure_socket;
use pgcat::pool::{ClientServerMap, ConnectionPool};
use pgcat::prometheus::start_metric_server;
use pgcat::stats::{Collector, Reporter, REPORTER};
use tracing_subscriber;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = cmd_args::parse();
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(),
};
logger::init(&args);
info!("Welcome to PgCat! Meow. (Version {})", VERSION);