Crates.io | loge |
lib.rs | loge |
version | 0.4.2 |
source | src |
created_at | 2020-01-15 05:37:49.667347 |
updated_at | 2020-06-08 05:27:51.81769 |
description | A analysis friendly logger with formatted output. |
homepage | |
repository | https://github.com/psiace/loge |
max_upload_size | |
id | 198518 |
size | 43,833 |
It helps to be diligent in recording and willing to review.
A simple logger with formatted output for easy analysis. Free your productivity start with best practices logs.
loge
is currently controlled by features and environment variables:
chrono
;json
, you also need to enable chrono
;colored
.target
, fileline
or json
. (Set environment variable LOGE_FORMAT
.)Examples:
target: date time [level] target ... message
(enable chrono
) or level target ... message
:
fileline: date time [level] file - target (line) ... message
(enable chrono
) or level file - target (line) ... message
:
json: You should enable json
and chrono
; for pretty output, enable colored
.
{
"time": "2020-02-02 18:33:33.645",
"level": "ERROR",
"message": "boom -> tests/simple-jsonified-log.rs:17",
"service": {
"name": "loge",
"version": "0.4.1"
},
"location": {
"file": "tests/simple-jsonified-log.rs",
"line": 17,
"target": "simple_jsonified_log::tests"
}
}
file: If you want to print log to a file, enable it, and you will see output both in terminal and file.
At first, you should add it to your Cargo.toml
file.
[dependencies]
log = "0.4.8"
loge = "0.4.2"
After that, set the RUST_LOG
& LOGE_FORMAT
variable in your code and initialize the logger.
std::env::set_var("RUST_LOG", "trace");
std::env::set_var("LOGE_FORMAT", "target"); // `fileline` or `json`(need enable `json` and `chrono`)
loge::init(); // If you enable `file`, you can't use this func.
// Or `loge::init_with_file("your-app.log");`, but need enable `file`, and will see output both in terminal and file.
Just run your project, you will get logs in the terminal.
Chojan Shang - @PsiACE - psiace@outlook.com
Project Link: https://github.com/psiace/loge
Licensed under either of:
pretty_env_log
.rust-simple_logger
.file-logger
.