mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-02-09 01:59:16 +08:00
SS_LOG_VERBOSE_LEVEL and SS_LOG_WITHOUT_TIME environment variable
ref #691
This commit is contained in:
@@ -579,6 +579,11 @@ Example configuration:
|
||||
}
|
||||
```
|
||||
|
||||
### Environment Variables
|
||||
|
||||
- `SS_LOG_VERBOSE_LEVEL`: Logging level for binaries (`sslocal`, `ssserver` and `ssmanager`). It is valid only when command line argument `-v` is not applied. Example: `SS_LOG_VERBOSE_LEVEL=1`
|
||||
- `SS_LOG_WITHOUT_TIME`: Logging format for binaries (`sslocal`, `ssserver` and `ssmanager`). It is valid only when command line argument `--log-without-time` is not applied. Example `SS_LOG_WITHOUT_TIME=1`
|
||||
|
||||
## Supported Ciphers
|
||||
|
||||
### AEAD Ciphers
|
||||
|
||||
@@ -30,7 +30,8 @@ pub fn get_default_config_path() -> Option<PathBuf> {
|
||||
}
|
||||
|
||||
// UNIX global configuration file
|
||||
if cfg!(unix) {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let global_config_path = Path::new("/etc/shadowsocks-rust/config.json");
|
||||
if global_config_path.exists() {
|
||||
return Some(global_config_path.to_path_buf());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Loggin facilities
|
||||
|
||||
use std::path::Path;
|
||||
use std::{env, path::Path};
|
||||
|
||||
use clap::ArgMatches;
|
||||
use log::LevelFilter;
|
||||
@@ -18,8 +18,24 @@ where
|
||||
}
|
||||
|
||||
pub fn init_with_config(bin_name: &str, matches: &ArgMatches) {
|
||||
let debug_level = matches.occurrences_of("VERBOSE");
|
||||
let without_time = matches.is_present("LOG_WITHOUT_TIME");
|
||||
let mut debug_level = matches.occurrences_of("VERBOSE");
|
||||
if debug_level == 0 {
|
||||
// Override by SS_LOG_VERBOSE_LEVEL
|
||||
if let Ok(verbose_level) = env::var("SS_LOG_VERBOSE_LEVEL") {
|
||||
if let Ok(verbose_level) = verbose_level.parse::<u64>() {
|
||||
debug_level = verbose_level;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut without_time = matches.is_present("LOG_WITHOUT_TIME");
|
||||
if !without_time {
|
||||
if let Ok(log_without_time) = env::var("SS_LOG_WITHOUT_TIME") {
|
||||
if let Ok(log_without_time) = log_without_time.parse::<u32>() {
|
||||
without_time = log_without_time != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut pattern = String::new();
|
||||
if !without_time {
|
||||
|
||||
Reference in New Issue
Block a user