mirror of
https://github.com/YGGverse/htcount.git
synced 2026-03-31 09:05:41 +00:00
update export-svg to target-svg update usage example
This commit is contained in:
parent
31e310fae7
commit
599435f1ab
3 changed files with 11 additions and 10 deletions
13
README.md
13
README.md
|
|
@ -28,10 +28,11 @@ Export totals in multiple formats, such as JSON or SVG [badge](https://github.co
|
|||
## Usage
|
||||
|
||||
``` bash
|
||||
htcount --source /var/log/nginx/access.log\
|
||||
--export-json /path/to/totals.json\
|
||||
--export-svg /path/to/totals.svg
|
||||
htcount --source /var/log/nginx/access.log\
|
||||
--target-svg /path/to/badge.svg\
|
||||
--template-svg /path/to/counter/template.svg
|
||||
```
|
||||
* see `default/counter.svg`
|
||||
|
||||
### Options
|
||||
|
||||
|
|
@ -50,10 +51,10 @@ htcount --source /var/log/nginx/access.log\
|
|||
|
||||
[default: nginx]
|
||||
|
||||
--export-json <EXPORT_JSON>
|
||||
--target-json <TARGET_JSON>
|
||||
Export results to JSON file (e.g. `/path/to/stats.json`)
|
||||
|
||||
--export-svg <EXPORT_SVG>
|
||||
--target-svg <TARGET_SVG>
|
||||
Export results to SVG file (e.g. `/path/to/badge.svg`)
|
||||
|
||||
* use `{hits}` / `{hosts}` pattern to replace parsed values
|
||||
|
|
@ -101,7 +102,7 @@ Wants=network-online.target
|
|||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/htcount --source /var/log/nginx/access.log\
|
||||
--export-svg /var/www/htcount/visitors.svg\
|
||||
--target-svg /var/www/htcount/visitors.svg\
|
||||
--template-svg /path/to/default/template.svg\
|
||||
--ignore-host 127.0.0.1\
|
||||
--ignore-host 127.0.0.2\
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ pub struct Argument {
|
|||
|
||||
/// Export results to JSON file (e.g. `/path/to/stats.json`)
|
||||
#[arg(long)]
|
||||
pub export_json: Option<String>,
|
||||
pub target_json: Option<String>,
|
||||
|
||||
/// Export results to SVG file (e.g. `/path/to/badge.svg`)
|
||||
///
|
||||
/// * use `{hits}` / `{hosts}` pattern to replace parsed values
|
||||
#[arg(long)]
|
||||
pub export_svg: Option<String>,
|
||||
pub target_svg: Option<String>,
|
||||
|
||||
/// Use custom SVG file template with `{hits}` / `{hosts}` placeholders
|
||||
#[arg(long, default_value_t = String::from("default/counter.svg"))]
|
||||
|
|
|
|||
|
|
@ -90,12 +90,12 @@ fn main() -> anyhow::Result<()> {
|
|||
));
|
||||
}
|
||||
|
||||
if let Some(ref p) = argument.export_json {
|
||||
if let Some(ref p) = argument.target_json {
|
||||
let mut f = File::create(p)?;
|
||||
f.write_all(format!("{{\"hosts\":{hosts},\"hits\":{hits}}}").as_bytes())?;
|
||||
}
|
||||
|
||||
if let Some(ref p) = argument.export_svg {
|
||||
if let Some(ref p) = argument.target_svg {
|
||||
let t = std::fs::read_to_string(&argument.template_svg)?;
|
||||
let mut f = File::create(p)?;
|
||||
f.write_all(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue