{"id":16057999,"url":"https://github.com/psfried/test-logger","last_synced_at":"2025-03-18T05:30:26.499Z","repository":{"id":57669558,"uuid":"63287701","full_name":"psFried/test-logger","owner":"psFried","description":"Rust helper to initialize env_logger during unit and integration tests","archived":false,"fork":false,"pushed_at":"2019-01-14T15:52:55.000Z","size":4,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T07:11:58.580Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/psFried.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-14T00:01:28.000Z","updated_at":"2022-03-08T05:35:47.000Z","dependencies_parsed_at":"2022-09-10T11:11:27.367Z","dependency_job_id":null,"html_url":"https://github.com/psFried/test-logger","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psFried%2Ftest-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psFried%2Ftest-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psFried%2Ftest-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psFried%2Ftest-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/psFried","download_url":"https://codeload.github.com/psFried/test-logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243902285,"owners_count":20366260,"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":[],"created_at":"2024-10-09T03:05:48.262Z","updated_at":"2025-03-18T05:30:25.926Z","avatar_url":"https://github.com/psFried.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Test Logger\n===========\n\nSimple helper to initialize env_logger before unit and integration tests. Works on Stable Rust.\n\nRunning `cargo test` does not initialize a logging backend, so those of us who use the `log` crate do not get to see log output when a unit or integration test fails. This crate just provides a simple macro that provides a way to initialize an `env_logger` during unit and integration tests while still making tests somewhat ergonomic to write.\n\n## `test!`\n\nMany applications use logging to aid in debugging a running application, but unfortunately there's no simple way to initialize the logger prior to running unit and integration tests. The `test!` macro is just a simple wrapper to take care of initializing an `env_logger` prior to running tests. This ensures that log statements are printed to stdout during the tests. The macro ensures that the logger is initialized exactly once.\n\nuse the `test!` macro:\n\n```rust\ntest!(logs_are_printed_to_stdout_when_this_fails, {\n    assert!(subject.do_stuff_that_fails());\n});\n// The above macro expands to:\n#[test]\nfn logs_are_printed_to_stdout_when_this_fails() {\n    test_logger::ensure_env_logger_initialized();\n    assert!(subject.do_stuff_that_fails());\n}\n\ntest!(should_panic, simple_way_to_annotate_a_test_that_is_supposed_to_panic, {\n    panic!(\"I'm supposed to panic.\");\n});\n//expands to:\n#[test]\n#[should_panic]\nfn simple_way_to_annotate_a_test_that_is_supposed_to_panic() {\n    test_logger::ensure_env_logger_initialized();\n    assert!(subject.do_stuff_that_fails());\n}\n\n// alternate format to support any arbitrary attributes on the test function\ntest!(#[allow(dead_code)], this_test_function_will_have_the_dead_code_lint_disabled, {\n    ... \n    \n```\n\n### License\n\nLicensed under either of\n\n * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsfried%2Ftest-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpsfried%2Ftest-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsfried%2Ftest-logger/lists"}