{"id":28861961,"url":"https://github.com/tjardoo/ftail","last_synced_at":"2025-10-23T19:56:12.342Z","repository":{"id":256769966,"uuid":"855106232","full_name":"tjardoo/ftail","owner":"tjardoo","description":"Ftail is simple logging implementation for the `log` crate with support for multiple channels.","archived":false,"fork":false,"pushed_at":"2025-09-25T15:12:52.000Z","size":64,"stargazers_count":14,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-25T17:22:55.227Z","etag":null,"topics":["logging","rust","rust-library"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/ftail","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tjardoo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-09-10T10:14:24.000Z","updated_at":"2025-09-25T15:12:55.000Z","dependencies_parsed_at":"2025-02-22T14:26:41.345Z","dependency_job_id":"bcb8dd0a-c1fc-44f2-8840-919694d18707","html_url":"https://github.com/tjardoo/ftail","commit_stats":null,"previous_names":["tjardoo/ftail"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tjardoo/ftail","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjardoo%2Fftail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjardoo%2Fftail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjardoo%2Fftail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjardoo%2Fftail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tjardoo","download_url":"https://codeload.github.com/tjardoo/ftail/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjardoo%2Fftail/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280683920,"owners_count":26372970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-23T02:00:06.710Z","response_time":142,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["logging","rust","rust-library"],"created_at":"2025-06-20T06:08:33.482Z","updated_at":"2025-10-23T19:56:12.336Z","avatar_url":"https://github.com/tjardoo.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ftail\n\n**Ftail** is a simple logging implementation for the [`log`](https://crates.io/crates/log) crate with support for multiple channels, including console output, files, and custom loggers.\n\n---\n\n## Features\n\n* Multiple logging channels: console, formatted console, single file, daily file, and custom\n* Level and target filtering\n* Optional timestamp formatting and timezone support\n* Automatic log rotation and retention\n* Use `RUST_LOG` environment variable for dynamic log level control (use '_env_level' postfix)\n\n---\n\n## Quick Start\n\nAdd Ftail to your `Cargo.toml`:\n\n```toml\n[dependencies]\nftail = \"0.3\"\n```\n\nInitialize Ftail in your `main.rs` or `lib.rs`:\n\n```rust\nuse ftail::Ftail;\nuse log::LevelFilter;\n\nfn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    Ftail::new()\n        .console(LevelFilter::Info)        // log to console\n        .daily_file(\"logs\", LevelFilter::Error) // log errors to daily files\n        .init()?; // initialize logger\n\n    log::info!(\"Hello, Ftail!\");\n    log::error!(\"This is an error message\");\n    Ok(())\n}\n```\n\n---\n\n## Configuration Options\n\n| Option               | Description                      | Notes                         |\n| -------------------- | -------------------------------- | ----------------------------- |\n| `.datetime_format()` | Set the datetime format          | Ex: `\"%Y-%m-%d %H:%M:%S%.3f\"` |\n| `.timezone()`        | Set the timezone                 | Requires `timezone` feature   |\n| `.max_file_size()`   | Maximum file size in MB          | Older logs renamed `.old{N}`  |\n| `.retention_days()`  | Number of days to keep log files | Daily file only               |\n| `.filter_levels()`   | Log only the specified levels    | `Vec\u003cLevel\u003e`                  |\n| `.filter_targets()`  | Log only the specified targets   | `Vec\u003c\u0026str\u003e`                   |\n\n---\n\n## Channels\n\n### Console\n\nLogs to the standard output without formatting.\n\n```rust\nFtail::new()\n    .console(LevelFilter::Trace)\n    .init()?;\n```\n\n**Output:**\n\n```text\n2024-09-13 17:35:18 TRACE console This is a trace message\n2024-09-13 17:35:18 DEBUG console This is a debug message\n2024-09-13 17:35:18 INFO foo bar\n2024-09-13 17:35:18 WARN console This is a warning message\n2024-09-13 17:35:18 ERROR console This is an error message\n```\n\n---\n\n### Formatted Console\n\nLogs with formatted and colored output.\n\n```rust\nFtail::new()\n    .formatted_console(LevelFilter::Trace)\n    .init()?;\n```\n\n**Output:**\n\n```text\n2024-09-13 17:35:37 · TRACE\nThis is a trace message\nexamples/formatted_console/src/main.rs:9\n\n2024-09-13 17:35:37 · DEBUG\nThis is a debug message\nexamples/formatted_console/src/main.rs:11\n```\n\n---\n\n### Single File\n\nLogs to a single file (e.g., `logs/demo.log`).\n\n```rust\nFtail::new()\n    .single_file(Path::new(\"logs/demo.log\"), true, LevelFilter::Trace)\n    .init()?;\n```\n\n* `append = true` keeps existing logs, `false` overwrites.\n\n---\n\n### Daily File\n\nLogs to daily files in a directory (e.g., `logs/2025-09-25.log`).\n\n```rust\nFtail::new()\n    .daily_file(Path::new(\"logs\"), LevelFilter::Trace)\n    .init()?;\n```\n\n* Automatically rotates files per day.\n\n---\n\n### Custom Channel\n\nCreate your own logger by implementing the `log::Log` trait:\n\n```rust\nFtail::new()\n    .custom(\n        |config| Box::new(CustomLogger { config }) as Box\u003cdyn Log + Send + Sync\u003e,\n        LevelFilter::Debug,\n    )\n    .datetime_format(\"%H:%M:%S%.3f\")\n    .init()?;\n\nstruct CustomLogger {\n    config: ftail::Config,\n}\n\nimpl log::Log for CustomLogger {\n    fn enabled(\u0026self, metadata: \u0026log::Metadata) -\u003e bool {\n        metadata.level() \u003c= self.config.level_filter\n    }\n\n    fn log(\u0026self, record: \u0026log::Record) {\n        if !self.enabled(record.metadata()) {\n            return;\n        }\n        let time = chrono::Local::now()\n            .format(\u0026self.config.datetime_format)\n            .to_string();\n        println!(\"[{}] {}: {}\", time, record.level(), record.args());\n    }\n\n    fn flush(\u0026self) {}\n}\n```\n\n**Output:**\n\n```text\n19:37:22.402 [DEBUG] This is a debug message\n19:37:22.403 [INFO] bar\n19:37:22.403 [WARN] This is a warning message\n19:37:22.403 [ERROR] This is an error message\n```\n\n---\n\n## Tips\n\n* Use `.console(LevelFilter::Debug)` for development.\n* Use `.daily_file()` in production to organize logs by date.\n* Combine `.max_file_size()` and `.retention_days()` to prevent disk bloat.\n* Only enable the channels you need to reduce overhead by disabling default features in `Cargo.toml`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftjardoo%2Fftail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftjardoo%2Fftail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftjardoo%2Fftail/lists"}