fix(core): change trace log format
This commit is contained in:
parent
3a51efda2c
commit
799474a0fc
|
@ -23,7 +23,9 @@ extern crate lazy_static;
|
||||||
use clap::{App, AppSettings, Arg, SubCommand};
|
use clap::{App, AppSettings, Arg, SubCommand};
|
||||||
use cli::{CliModule, CliModuleArgs};
|
use cli::{CliModule, CliModuleArgs};
|
||||||
use logging::FileProxy;
|
use logging::FileProxy;
|
||||||
use simplelog::{CombinedLogger, ConfigBuilder, LevelFilter, TermLogger, TerminalMode, WriteLogger};
|
use simplelog::{
|
||||||
|
CombinedLogger, ConfigBuilder, LevelFilter, TermLogger, TerminalMode, WriteLogger,
|
||||||
|
};
|
||||||
|
|
||||||
mod cli;
|
mod cli;
|
||||||
mod engine;
|
mod engine;
|
||||||
|
@ -33,11 +35,8 @@ const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
const LOG_FILE_NAME: &str = "espanso.log";
|
const LOG_FILE_NAME: &str = "espanso.log";
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref CLI_HANDLERS: Vec<CliModule> = vec![
|
static ref CLI_HANDLERS: Vec<CliModule> =
|
||||||
cli::path::new(),
|
vec![cli::path::new(), cli::log::new(), cli::worker::new(),];
|
||||||
cli::log::new(),
|
|
||||||
cli::worker::new(),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -76,10 +75,12 @@ fn main() {
|
||||||
.version(VERSION)
|
.version(VERSION)
|
||||||
.author("Federico Terzi")
|
.author("Federico Terzi")
|
||||||
.about("A Privacy-first, Cross-platform Text Expander")
|
.about("A Privacy-first, Cross-platform Text Expander")
|
||||||
.arg(Arg::with_name("v")
|
.arg(
|
||||||
|
Arg::with_name("v")
|
||||||
.short("v")
|
.short("v")
|
||||||
.multiple(true)
|
.multiple(true)
|
||||||
.help("Sets the level of verbosity"))
|
.help("Sets the level of verbosity"),
|
||||||
|
)
|
||||||
// .subcommand(SubCommand::with_name("cmd")
|
// .subcommand(SubCommand::with_name("cmd")
|
||||||
// .about("Send a command to the espanso daemon.")
|
// .about("Send a command to the espanso daemon.")
|
||||||
// .subcommand(SubCommand::with_name("exit")
|
// .subcommand(SubCommand::with_name("exit")
|
||||||
|
@ -110,8 +111,7 @@ fn main() {
|
||||||
// .about("MacOS and Linux only. Register espanso in the system daemon manager."))
|
// .about("MacOS and Linux only. Register espanso in the system daemon manager."))
|
||||||
// .subcommand(SubCommand::with_name("unregister")
|
// .subcommand(SubCommand::with_name("unregister")
|
||||||
// .about("MacOS and Linux only. Unregister espanso from the system daemon manager."))
|
// .about("MacOS and Linux only. Unregister espanso from the system daemon manager."))
|
||||||
.subcommand(SubCommand::with_name("log")
|
.subcommand(SubCommand::with_name("log").about("Print the daemon logs."))
|
||||||
.about("Print the daemon logs."))
|
|
||||||
// .subcommand(SubCommand::with_name("start")
|
// .subcommand(SubCommand::with_name("start")
|
||||||
// .about("Start the daemon spawning a new process in the background."))
|
// .about("Start the daemon spawning a new process in the background."))
|
||||||
// .subcommand(SubCommand::with_name("stop")
|
// .subcommand(SubCommand::with_name("stop")
|
||||||
|
@ -120,21 +120,25 @@ fn main() {
|
||||||
// .about("Restart the espanso daemon."))
|
// .about("Restart the espanso daemon."))
|
||||||
// .subcommand(SubCommand::with_name("status")
|
// .subcommand(SubCommand::with_name("status")
|
||||||
// .about("Check if the espanso daemon is running or not."))
|
// .about("Check if the espanso daemon is running or not."))
|
||||||
.subcommand(SubCommand::with_name("path")
|
.subcommand(
|
||||||
|
SubCommand::with_name("path")
|
||||||
.about("Prints all the espanso directory paths to easily locate configuration and matches.")
|
.about("Prints all the espanso directory paths to easily locate configuration and matches.")
|
||||||
.subcommand(SubCommand::with_name("config")
|
.subcommand(SubCommand::with_name("config").about("Print the current config folder path."))
|
||||||
.about("Print the current config folder path."))
|
.subcommand(
|
||||||
.subcommand(SubCommand::with_name("packages")
|
SubCommand::with_name("packages").about("Print the current packages folder path."),
|
||||||
.about("Print the current packages folder path."))
|
)
|
||||||
.subcommand(SubCommand::with_name("data")
|
.subcommand(
|
||||||
|
SubCommand::with_name("data")
|
||||||
.about("Print the current data folder path.")
|
.about("Print the current data folder path.")
|
||||||
.setting(AppSettings::Hidden)) // Legacy path
|
.setting(AppSettings::Hidden),
|
||||||
.subcommand(SubCommand::with_name("runtime")
|
) // Legacy path
|
||||||
.about("Print the current runtime folder path."))
|
.subcommand(
|
||||||
.subcommand(SubCommand::with_name("default")
|
SubCommand::with_name("runtime").about("Print the current runtime folder path."),
|
||||||
.about("Print the default configuration file path."))
|
)
|
||||||
.subcommand(SubCommand::with_name("base")
|
.subcommand(
|
||||||
.about("Print the default match file path."))
|
SubCommand::with_name("default").about("Print the default configuration file path."),
|
||||||
|
)
|
||||||
|
.subcommand(SubCommand::with_name("base").about("Print the default match file path.")),
|
||||||
)
|
)
|
||||||
// .subcommand(SubCommand::with_name("match")
|
// .subcommand(SubCommand::with_name("match")
|
||||||
// .about("List and execute matches from the CLI")
|
// .about("List and execute matches from the CLI")
|
||||||
|
@ -179,17 +183,19 @@ fn main() {
|
||||||
// .arg(Arg::with_name("full")
|
// .arg(Arg::with_name("full")
|
||||||
// .help("Print all package info")
|
// .help("Print all package info")
|
||||||
// .long("full")))
|
// .long("full")))
|
||||||
|
|
||||||
// .subcommand(SubCommand::with_name("refresh")
|
// .subcommand(SubCommand::with_name("refresh")
|
||||||
// .about("Update espanso package index"))
|
// .about("Update espanso package index"))
|
||||||
// )
|
// )
|
||||||
.subcommand(SubCommand::with_name("worker")
|
.subcommand(
|
||||||
|
SubCommand::with_name("worker")
|
||||||
.setting(AppSettings::Hidden)
|
.setting(AppSettings::Hidden)
|
||||||
.arg(Arg::with_name("reload")
|
.arg(
|
||||||
|
Arg::with_name("reload")
|
||||||
.short("r")
|
.short("r")
|
||||||
.long("reload")
|
.long("reload")
|
||||||
.required(false)
|
.required(false)
|
||||||
.takes_value(false))
|
.takes_value(false),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
// .subcommand(install_subcommand)
|
// .subcommand(install_subcommand)
|
||||||
// .subcommand(uninstall_subcommand);
|
// .subcommand(uninstall_subcommand);
|
||||||
|
@ -216,7 +222,10 @@ fn main() {
|
||||||
if let Some(handler) = handler {
|
if let Some(handler) = handler {
|
||||||
let log_proxy = FileProxy::new();
|
let log_proxy = FileProxy::new();
|
||||||
if handler.enable_logs {
|
if handler.enable_logs {
|
||||||
let config = ConfigBuilder::new().set_time_to_local(true).build();
|
let config = ConfigBuilder::new()
|
||||||
|
.set_time_to_local(true)
|
||||||
|
.set_location_level(LevelFilter::Off)
|
||||||
|
.build();
|
||||||
|
|
||||||
CombinedLogger::init(vec![
|
CombinedLogger::init(vec![
|
||||||
TermLogger::new(log_level, config.clone(), TerminalMode::Mixed),
|
TermLogger::new(log_level, config.clone(), TerminalMode::Mixed),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user