Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mendelsshop/simple_file_logger
Basic file logger for Rust
https://github.com/mendelsshop/simple_file_logger
logging
Last synced: 2 months ago
JSON representation
Basic file logger for Rust
- Host: GitHub
- URL: https://github.com/mendelsshop/simple_file_logger
- Owner: mendelsshop
- License: mit
- Created: 2022-09-04T20:00:01.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-09T13:18:08.000Z (8 months ago)
- Last Synced: 2024-09-13T22:54:00.373Z (3 months ago)
- Topics: logging
- Language: Rust
- Homepage: https://crates.io/crates/simple_file_logger
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [![crates.io](https://img.shields.io/crates/v/simple_file_logger.svg?label=latest%20version)](https://crates.io/crates/simple_file_logger) [![Crates.io](https://img.shields.io/crates/d/simple_file_logger?label=crates.io%20downloads)](https://crates.io/crates/simple_file_logger) [![docs.rs](https://docs.rs/simple_file_logger/badge.svg)](https://docs.rs/simple_file_logger/)
# Simple File Logger
A simple file logger for rust.
Very basic setup, just provide an app name and an optional log level.
```rust
use simple_file_logger::{init_logger, LogLevel};
use log::info;fn main() {
init_logger("my_app", Loglevel::Info).unwrap();
info!("Hello, world!");
}
```or if you want to use the default log level (and save typing around 15 characters):
```rust
use simple_file_logger::init_logger;fn main() {
init_logger!("my_app").unwrap();
info!("Hello, world!");
}
```The log levels are: `trace`, `debug`, `info` , `warn`, `error`.
The log file is located:
| OS | Path | Example |
| --- | --- | --- |
|Windows| %FOLDERID_LocalAppData%\program_name\log\program_nametime_stamp.log | C:\Users\username\AppData\Local\program_name\log\program_name_2020-05-01T12-34-56.log|
|Linux| $XDG_DATA_HOME/program_name/log/program_name_time_stamp.log |/home/username/.local/share/program_name/log/program_name_2020-05-01T12-34-56.log|
|macOS| $HOME/Library/Application Support/program_name/log/program_nametime_stamp.log |Users/username/Library/Application Support/program_name/log/program_name_2020-05-01T12-34-56.log|## Optional features
- clap: enable clap parsing for LogLevel, Uses the ValueEnum proc-macro.
- serde: enable serde serialization and deserialization on LogLevel.