Default log level changed to INFO; added option to enable TRACE log level

This commit is contained in:
veeso
2021-12-12 12:54:36 +01:00
committed by Christian Visintin
parent e6ba4d8430
commit 2a3d4f2670
11 changed files with 57 additions and 72 deletions

View File

@@ -59,6 +59,9 @@ Released on FIXME:
- The supported parameters are described at <https://github.com/veeso/ssh2-config>.
- If the field is left empty, **no file will be loaded**.
- **By default, no file will be used**.
- **Less verbose logging**:
- By default the log level is now set to `INFO`
- It is now possible to enable the `TRACE` level with the `-D` CLI option.
- Dependencies:
- Updated `tui-realm` to `1.3.0`
- Updated `tui-realm-stdlib` to `1.1.4`

View File

@@ -63,7 +63,7 @@ Don't set other labels to your issue, not even priority.
When you open a bug try to be the most precise as possible in describing your issue. I'm not saying you should always be that precise, since sometimes it's very easy for maintainers to understand what you're talking about. Just try to be reasonable to understand sometimes we might not know what you're talking about or we just don't have the technical knowledge you might think.
Please always provide the environment you're working on and consider that we don't provide any support for older version of termscp, at least for those not classified as LTS (if we'll ever have them).
If you can, provide the log file or the snippet involving your issue. You can find in the [user manual](docs/man.md) the location of the log file.
If you can, provide the log file or the snippet involving your issue. You can find in the [user manual](docs/man.md) the location of the log file. Please, if you can, enable the **debug mode**, before submitting the log, in order to provide us with a better overview of the problem.
Last but not least: the template I've written must be used. Full stop.
Maintainers will may add additional labels to your issue:

View File

@@ -455,17 +455,13 @@ termscp writes a log file for each session, which is written at
- `FOLDERID_RoamingAppData\termscp\termscp.log` on Windows
the log won't be rotated, but will just be truncated after each launch of termscp, so if you want to report an issue and you want to attach your log file, keep in mind to save the log file in a safe place before using termscp again.
The log file always reports in *trace* level, so it is kinda verbose.
The logging by default reports in *INFO* level, so it is not very verbose.
If you want to submit an issue, please, if you can, reproduce the issue with the level set to `TRACE`, to do so, launch termscp with
the `-D` CLI option.
I know you might have some questions regarding log files, so I made a kind of a Q/A:
> Is it possible to reduce verbosity?
No. The reason is quite simple: when an issue happens, you must be able to know what's causing it and the only way to do that, is to have the log file with the maximum verbosity level set.
> If trace level is set for logging, is the file going to reach a huge size?
Probably not, unless you never quit termscp, but I think that's unlikely to happen. A long session may produce up to 10MB of log files (I said a long session), but I think a normal session won't exceed 2MB.
> I don't want logging, can I turn it off?
Yes, you can. Just start termscp with `-q or --quiet` option. You can alias termscp to make it persistent. Remember that logging is used to diagnose issues, so since behind every open source project, there should always be this kind of mutual help, keeping log files might be your way to support the project 😉. I don't want you to feel guilty, but just to say.

View File

@@ -454,17 +454,13 @@ termscp escribe un archivo de registro para cada sesión, que se escribe en
- `FOLDERID_RoamingAppData\termscp\termscp.log` en Windows
el registro no se rotará, sino que se truncará después de cada lanzamiento de termscp, por lo que si desea informar un problema y desea adjuntar su archivo de registro, recuerde guardar el archivo de registro en un lugar seguro antes de usar termscp de nuevo.
El archivo de registro siempre informa en el nivel de *seguimiento*, por lo que es un poco detallado.
El registro por defecto informa en el nivel *INFO*, por lo que no es muy detallado.
Si desea enviar un problema, por favor, si puede, reproduzca el problema con el nivel establecido en "TRACE", para hacerlo, inicie termscp con
la opción CLI `-D`.
Sé que es posible que tenga algunas preguntas sobre los archivos de registro, así que hice una especie de Q/A:
> ¿Es posible reducir la verbosidad?
No. La razón es bastante simple: cuando ocurre un problema, debe poder saber qué lo está causando y la única forma de hacerlo es tener el archivo de registro con el nivel de verbosidad máximo establecido.
> Si el nivel de seguimiento está configurado para el registro, ¿el archivo alcanzará un tamaño enorme?
Probablemente no, a menos que nunca cerra termscp, pero creo que es poco probable que eso suceda. Una sesión larga puede producir hasta 10 MB de archivos de registro (dije una sesión larga), pero creo que una sesión normal no excederá los 2 MB.
> No quiero el registro, ¿puedo apagarlo?
Sí tu puedes. Simplemente inicie termscp con la opción `-q o --quiet`. Puede alias termscp para que sea persistente. Recuerde que el registro se usa para diagnosticar problemas, por lo que, dado que detrás de cada proyecto de código abierto, siempre debe haber este tipo de ayuda mutua, mantener los archivos de registro puede ser su forma de respaldar el proyecto 😉.

View File

@@ -25,7 +25,7 @@
- [Transfer page](#transfer-page)
- [Misc](#misc)
- [Éditeur de texte ✏](#éditeur-de-texte-)
- [Enregistrement 🩺](#enregistrement-)
- [Fichier Journal 🩺](#fichier-journal-)
- [Notifications 📫](#notifications-)
## Usage ❓
@@ -443,7 +443,7 @@ Si le fichier se trouve sur l'hôte distant, le fichier sera d'abord télécharg
---
## Enregistrement 🩺
## Fichier Journal 🩺
termscp écrit un fichier journal pour chaque session, qui est écrit à
@@ -451,18 +451,15 @@ termscp écrit un fichier journal pour chaque session, qui est écrit à
- `$HOME/Library/Application Support/termscp/termscp.log` sous MacOs
- `FOLDERID_RoamingAppData\termscp\termscp.log` sous Windows
le journal ne sera pas tourné, mais sera simplement tronqué après chaque lancement de termscp, donc si vous souhaitez signaler un problème et que vous souhaitez joindre votre fichier journal, n'oubliez pas de sauvegarder le fichier journal dans un endroit sûr avant de l'utiliser termscp à nouveau.
Le fichier journal rapporte toujours au niveau *trace*, il est donc un peu détaillé.
le journal ne sera pas tourné, mais sera simplement tronqué après chaque lancement de termscp, donc si vous souhaitez signaler un problème et que vous souhaitez joindre votre fichier journal, n'oubliez pas de sauvegarder le fichier journal dans un endroit sûr avant de l'utiliser termescp à nouveau.
La journalisation par défaut se rapporte au niveau *INFO*, elle n'est donc pas très détaillée.
Si vous souhaitez soumettre un problème, veuillez, si vous le pouvez, reproduire le problème avec le niveau défini sur `TRACE`, pour ce faire, lancez termscp avec
l'option CLI `-D`.
Je sais que vous pourriez avoir des questions concernant les fichiers journaux, alors j'ai fait une sorte de Q/R :
> Est-il possible de réduire la verbosité ?
Non. La raison est assez simple : lorsqu'un problème survient, vous devez être capable de savoir ce qui en est la cause et la seule façon de le faire est d'avoir le fichier journal avec le niveau de verbosité maximum défini.
> Si le niveau de trace est défini pour la journalisation, le fichier va-t-il atteindre une taille énorme ?
Probablement pas, à moins que vous ne quittiez jamais termscp, mais je pense que cela est peu probable. Une longue session peut produire jusqu'à 10 MB de fichiers journaux (j'ai dit une longue session), mais je pense qu'une session normale ne dépassera pas 2 MB.
> Je ne veux pas me connecter, puis-je le désactiver ?
Oui, vous pouvez. Démarrez simplement termscp avec l'option `-q ou --quiet`. Vous pouvez créer un alias termcp pour le rendre persistant. N'oubliez pas que la journalisation est utilisée pour diagnostiquer les problèmes, donc puisque derrière chaque projet open source, il devrait toujours y avoir ce genre d'aide mutuelle, la conservation des fichiers journaux peut être votre moyen de soutenir le projet 😉. Je ne veux pas que tu te sentes coupable, mais juste pour dire.

View File

@@ -129,7 +129,7 @@
## Riguardo a termscp 🖥
Termscp è un file transfer ed explorer ricco di funzionalità, con supporto a SCP/SFTP/FTP/S3. Basicamente è un utility su terminale con una terminal user-interface per connettersi a server remoti per scambiare file ed interagire con il file system sia locale che remoto. È compatibile con **Linux**, **MacOS**, **FreeBSD** e **Windows**.
Termscp è un file transfer ed explorer ricco di funzionalità, con supporto a SCP/SFTP/FTP/S3. In pratica è un utility su terminale con una terminal user-interface per connettersi a server remoti per scambiare file ed interagire con il file system sia locale che remoto. È compatibile con **Linux**, **MacOS**, **FreeBSD** e **Windows**.
![Explorer](/assets/images/explorer.gif)

View File

@@ -451,22 +451,18 @@ termscp scrive un file di log per ogni sessione, nel percorso seguente:
- `FOLDERID_RoamingAppData\termscp\termscp.log` su Windows
Il log non viene ruotato, ma viene troncato ad ogni lancio di termscp, quindi se devi riportare un issue, non avviare termscp fino a che non avrai salvato il file di log.
I log sono sempre riportati a livello di *trace*, quindi sono piuttosto parlanti.
I log sono di default riportati a livello *INFO*, quindi non sono particolarmente parlanti.
Se vuoi riportare un problema, se riesci, riproduci l'errore lanciando termscp in modalità di debug, in modo da fornire un log più dettagliato.
Per farlo, lancia termscp con l'opzione `-D`.
Ho scritto questo FAQ sui log, visto che potresti avere qualche dubbio:
> Si può ridurre la verbosità?
No. Il motivo è piuttosto semplice: quando c'è un problema, devi sapere cosa lo sta causando e l'unico modo per farlo e avere il log alla massima verbosità per avere la massima precisione sul controllo del flusso.
> Se trace è il livello di verbosità, non si raggiungono dimensioni enormi?
Probabilmente no, a meno che tu tenga sempre termscp acceso. Una lunga sessione potrebbe raggiungere i 10MB di log, ma una sessione media all'incirca 2MB.
> Non voglio il logging, posso disabilitarlo?
> Non voglio il log, posso disabilitarlo?
Sì, puoi. Basta lanciare termscp con `-q or --quiet` come opzione. Puoi mantenerlo persistente salvandolo come alias nella tua shell. Ricorda che i log vengono usati per diagnosticare problemi e considerando che questo è un progetto open-source è anche un modo per contribuire al progetto 😉. Non voglio far sentire in colpa nessuno, ma tanto per dire.
> Il logging è sicuro?
> Il log è sicuro?
Se ti chiedi se il log espone dati sensibili, il log non espone nessuna password o dato sensibile.

View File

@@ -453,17 +453,13 @@ termscp writes a log file for each session, which is written at
- `FOLDERID_RoamingAppData\termscp\termscp.log` on Windows
the log won't be rotated, but will just be truncated after each launch of termscp, so if you want to report an issue and you want to attach your log file, keep in mind to save the log file in a safe place before using termscp again.
The log file always reports in *trace* level, so it is kinda verbose.
The logging by default reports in *INFO* level, so it is not very verbose.
If you want to submit an issue, please, if you can, reproduce the issue with the level set to `TRACE`, to do so, launch termscp with
the `-D` CLI option.
I know you might have some questions regarding log files, so I made a kind of a Q/A:
> Is it possible to reduce verbosity?
No. The reason is quite simple: when an issue happens, you must be able to know what's causing it and the only way to do that, is to have the log file with the maximum verbosity level set.
> If trace level is set for logging, is the file going to reach a huge size?
Probably not, unless you never quit termscp, but I think that's unlikely to happen. A long session may produce up to 10MB of log files (I said a long session), but I think a normal session won't exceed 2MB.
> I don't want logging, can I turn it off?
Yes, you can. Just start termscp with `-q or --quiet` option. You can alias termscp to make it persistent. Remember that logging is used to diagnose issues, so since behind every open source project, there should always be this kind of mutual help, keeping log files might be your way to support the project 😉. I don't want you to feel guilty, but just to say.

View File

@@ -445,15 +445,13 @@ termscp会为每个会话创建一个日志文件该文件在
- `$HOME/Library/Application Support/termscp/termscp.log` -- MacOs
- `FOLDERID_RoamingAppData\termscp\termscp.log` -- Windows
日志不会滚动,只是在每次启动 termscp 后被截断,所以如果想报告一个问题并想附上你的日志文件,再次启动 termscp 之前请先将日志文件保存在一个安全的地方。日志文件总是以*trace*级别报告所以它有点冗长。我知道你可能有一些关于日志文件的问题所以我做了一个Q/A
日志不会被轮换,但只会在每次启动 termcp 后被截断,因此如果想报告问题并希望附加您的日志文件,请记住在使用前将日志文件保存在安全的地方 再次termscp。
默认情况下,日志记录在 *INFO* 级别报告,因此它不是很详细。
> 有没有可能降低日志级别?
如果你想提交一个问题,如果可以的话,请在级别设置为`TRACE`的情况下重现问题为此启动termscp
`-D` CLI 选项。
不可以,原因很简单:当一个问题发生时,你必须能够知道是什么原因造成的,而唯一的办法就是在日志文件中设置记录最多的细节。
> 如果日志级别设置为trace会产生很大的文件吗
应该不会除非你从不退出termscp但我认为这很可能发生。一个长的会话可能会产生高达10MB的日志文件我说的是一个长的会话但我认为一个正常的会话不会超过2MB。
我知道您可能对日志文件有一些疑问,所以我做了一个问答:
> 我不希望有日志记录,我可以把它关掉吗?

View File

@@ -56,7 +56,7 @@ mod utils;
// namespaces
use activity_manager::{ActivityManager, NextActivity};
use filetransfer::FileTransferParams;
use system::logging;
use system::logging::{self, LogLevel};
enum Task {
Activity(NextActivity),
@@ -78,6 +78,8 @@ Please, consider supporting the author <https://ko-fi.com/veeso>")]
struct Args {
#[argh(switch, short = 'c', description = "open termscp configuration")]
config: bool,
#[argh(switch, short = 'D', description = "enable TRACE log level")]
debug: bool,
#[argh(option, short = 'P', description = "provide password from CLI")]
password: Option<String>,
#[argh(switch, short = 'q', description = "disable logging")]
@@ -110,7 +112,7 @@ struct Args {
struct RunOpts {
remote: Option<FileTransferParams>,
ticks: Duration,
log_enabled: bool,
log_level: LogLevel,
task: Task,
}
@@ -119,7 +121,7 @@ impl Default for RunOpts {
Self {
remote: None,
ticks: Duration::from_millis(10),
log_enabled: true,
log_level: LogLevel::Info,
task: Task::Activity(NextActivity::Authentication),
}
}
@@ -136,10 +138,8 @@ fn main() {
}
};
// Setup logging
if run_opts.log_enabled {
if let Err(err) = logging::init() {
eprintln!("Failed to initialize logging: {}", err);
}
if let Err(err) = logging::init(run_opts.log_level) {
eprintln!("Failed to initialize logging: {}", err);
}
// Read password from remote
if let Err(err) = read_password(&mut run_opts) {
@@ -174,8 +174,10 @@ fn parse_args(args: Args) -> Result<RunOpts, String> {
run_opts.task = Task::Activity(NextActivity::SetupActivity);
}
// Logging
if args.quiet {
run_opts.log_enabled = false;
if args.debug {
run_opts.log_level = LogLevel::Trace;
} else if args.quiet {
run_opts.log_level = LogLevel::Off;
}
// Match ticks
run_opts.ticks = Duration::from_millis(args.ticks);

View File

@@ -29,14 +29,15 @@
use crate::system::environment::{get_log_paths, init_config_dir};
use crate::utils::file::open_file;
// ext
use simplelog::{ConfigBuilder, LevelFilter, WriteLogger};
pub use simplelog::LevelFilter as LogLevel;
use simplelog::{ConfigBuilder, WriteLogger};
use std::fs::File;
use std::path::PathBuf;
/// ### init
///
/// Initialize logger
pub fn init() -> Result<(), String> {
pub fn init(level: LogLevel) -> Result<(), String> {
// Init config dir
let config_dir: PathBuf = match init_config_dir() {
Ok(Some(p)) => p,
@@ -56,7 +57,7 @@ pub fn init() -> Result<(), String> {
.set_time_format_str("%Y-%m-%dT%H:%M:%S%z")
.build();
// Make logger
WriteLogger::init(LevelFilter::Trace, config, file)
WriteLogger::init(level, config, file)
.map_err(|e| format!("Failed to initialize logger: {}", e))
}
@@ -67,6 +68,6 @@ mod test {
#[test]
fn test_system_logging_setup() {
assert!(init().is_ok());
assert!(init(LogLevel::Trace).is_ok());
}
}