Skip to content

Commit

Permalink
chore: upd log
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrita committed Apr 17, 2024
1 parent e546f7c commit 9004143
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 6 deletions.
85 changes: 84 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "peerban"
version = "0.1.0"
version = "0.1.1"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -16,6 +16,7 @@ log = "0.4.21"
async-trait = "0.1.79"
clap = { version = "4.5.4", features = ["derive", "env"] }
regex = "1.10.4"
chrono = "0.4.38"

[profile.opt]
inherits = "release"
Expand Down
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,28 @@ Options:

## Installation

### From Source

```shell
cargo install --git https://github.com/jerrita/peerban
```

> Docker & Binary is WIP
### Docker

```yaml
services:
peerban:
image: ghcr.io/jerrita/peerban:latest
container_name: peerban
restart: unless-stopped
environment:
- BACKEND=qb
- ENDPOINT=http://your-qbittorrent:8080
- AUTH=user:password
- SCAN=5
- PT=false # use the same logic on PT trackers, default skip
- CLEAR=false # clear all bans before start, default false
network_mode: host
```
## Backend Supports
Expand All @@ -47,7 +64,7 @@ cargo install --git https://github.com/jerrita/peerban
## RoadMap

- [x] ProtoType
- [ ] Container
- [x] Containerize
- [ ] WebUI
- [ ] Rule Hot-Update

Expand Down
18 changes: 17 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::io::Write;

use clap::Parser;
use log::{error, info, warn};

Expand Down Expand Up @@ -31,7 +33,21 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "info");
}
env_logger::init();
env_logger::builder()
.format(|buf, record| {
writeln!(buf, "{} [{}] {}",
chrono::Local::now().format("%Y-%m-%d %H:%M:%S"),
match record.level() {
log::Level::Error => "\x1b[31mERROR\x1b[0m",
log::Level::Warn => "\x1b[33mWARN\x1b[0m",
log::Level::Info => "\x1b[32mINFO\x1b[0m",
log::Level::Debug => "\x1b[34mDEBUG\x1b[0m",
log::Level::Trace => "\x1b[37mTRACE\x1b[0m",
},
record.args()
)
})
.init();

let args = Args::parse();
if args.backend != "qb" {
Expand Down

0 comments on commit 9004143

Please sign in to comment.