{"id":16064387,"url":"https://github.com/baoyachi/simple-log","last_synced_at":"2025-03-17T16:32:31.686Z","repository":{"id":43679334,"uuid":"317132045","full_name":"baoyachi/simple-log","owner":"baoyachi","description":"simple-log write by Rust","archived":false,"fork":false,"pushed_at":"2023-08-22T08:31:51.000Z","size":56,"stargazers_count":11,"open_issues_count":4,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-24T10:17:46.112Z","etag":null,"topics":["crates","log","log-rs","logger","logrs","logs","rust","rust-log","simple-log"],"latest_commit_sha":null,"homepage":"","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/baoyachi.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2020-11-30T06:33:55.000Z","updated_at":"2024-08-20T08:46:34.120Z","dependencies_parsed_at":"2024-08-21T02:47:11.545Z","dependency_job_id":null,"html_url":"https://github.com/baoyachi/simple-log","commit_stats":{"total_commits":94,"total_committers":1,"mean_commits":94.0,"dds":0.0,"last_synced_commit":"5d23b944b4390afeb8645b53c0148349c7197dd5"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baoyachi%2Fsimple-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baoyachi%2Fsimple-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baoyachi%2Fsimple-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baoyachi%2Fsimple-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baoyachi","download_url":"https://codeload.github.com/baoyachi/simple-log/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243871888,"owners_count":20361379,"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","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":["crates","log","log-rs","logger","logrs","logs","rust","rust-log","simple-log"],"created_at":"2024-10-09T05:06:48.236Z","updated_at":"2025-03-17T16:32:31.310Z","avatar_url":"https://github.com/baoyachi.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple-log\nA simple-log with local file or stdout write by Rust.\n\n\n[![Crates.io](https://img.shields.io/crates/v/simple-log)](https://crates.io/crates/simple-log)\n[![Crates.io](https://img.shields.io/crates/l/simple-log)](https://github.com/baoyachi/simple-log)\n[![depstatus](https://deps.rs/repo/github/baoyachi/simple-log/status.svg)](https://deps.rs/repo/github/baoyachi/simple-log)\n[![Crates.io](https://img.shields.io/crates/d/simple-log)](https://github.com/baoyachi/simple-log)\n\n## simple-log format output    \n```\n2020-12-07 15:06:03.260570000 [INFO] \u003cjson_log:16\u003e:info json simple_log\n2020-12-07 15:06:03.262106000 [WARN] \u003cjson_log:17\u003e:warn json simple_log\n2020-12-07 15:06:03.262174000 [ERROR] \u003cjson_log:18\u003e:error json simple_log\n```\n\n\n## Quick Use\n```toml\n[dependencies]\nsimple-log = \"{latest}\"\n```\n\n```rust\n#[macro_use]\nextern crate simple_log;\n\nfn main() {\n    simple_log::quick!(\"info\"); // also use empty args: simple_log::quick!();\n    // simple_log::quick!(); //use debug log_level\n    \n    debug!(\"test quick debug\");\n    info!(\"test quick info\");\n}\n```\n\n## Usage in project\n```toml\n[dependencies]\nsimple-log = \"{latest}\"\n```\n```rust\n#[macro_use]\nextern crate simple_log;\n\nuse simple_log::LogConfigBuilder;\n\nfn main() -\u003e Result\u003c(), String\u003e {\n    let config = LogConfigBuilder::builder()\n        .path(\"./log/builder_log.log\")\n        .size(1 * 100)\n        .roll_count(10)\n        .time_format(\"%Y-%m-%d %H:%M:%S.%f\") //E.g:%H:%M:%S.%f\n        .level(\"debug\")?\n        .output_file()\n        .output_console()\n        .build();\n\n    simple_log::new(config)?;\n    debug!(\"test builder debug\");\n    info!(\"test builder info\");\n    Ok(())\n}\n```\n\n## Config with toml\n```toml\n[dependencies]\nsimple-log = \"{latest}\"\ntoml = \"0.5.7\"\n```\n\n```rust\n#[macro_use]\nextern crate simple_log;\n\n#[macro_use]\nextern crate serde_derive;\n\nuse simple_log::LogConfig;\n\n#[derive(Deserialize)]\nstruct LogConfigWrap {\n    log_config: LogConfig,\n}\n\nfn main() {\n    let config = r#\"\n    [log_config]\n    path = \"./log/tmp.log\"\n    level = \"debug\"\n    size = 10\n    out_kind = [\"console\",\"file\"] # also configure only with file: out_kind = \"file\"  \n    roll_count = 10\n    time_format = \"%H:%M:%S.%f\"\n    \"#;\n    let wrap: LogConfigWrap = toml::from_str(config).unwrap();\n\n    simple_log::new(wrap.log_config).unwrap();//init log\n\n    info!(\"info toml simple_log\");\n    warn!(\"warn toml simple_log\");\n    error!(\"error toml simple_log\");\n}\n```\n\n## Config with json\n\n```toml\n[dependencies]\nsimple-log = \"{latest}\"\nserde_json = \"1\"\n```\n\n```rust\n#[macro_use]\nextern crate simple_log;\n\nuse simple_log::LogConfig;\n\nfn main() {\n    let config = r#\"\n    {\n        \"path\":\"./log/tmp.log\",\n        \"level\":\"debug\",\n        \"size\":10,\n        \"out_kind\":[\"console\",\"file\"],\n        \"roll_count\":10,\n        \"time_format\":\"%H:%M:%S.%f\"\n    }\"#;\n    let log_config: LogConfig = serde_json::from_str(config).unwrap();\n\n    simple_log::new(log_config).unwrap();//init log\n\n    info!(\"info json simple_log\");\n    warn!(\"warn json simple_log\");\n    error!(\"error json simple_log\");\n}\n```\n\n## examples\nMore than examples can see [examples](https://github.com/baoyachi/simple-log/tree/main/examples).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaoyachi%2Fsimple-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaoyachi%2Fsimple-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaoyachi%2Fsimple-log/lists"}