{"id":16373136,"url":"https://github.com/bbqsrc/eventlog","last_synced_at":"2025-03-16T15:33:33.095Z","repository":{"id":57626431,"uuid":"274761666","full_name":"bbqsrc/eventlog","owner":"bbqsrc","description":"A log-compatible wrapper around the Windows Event Log API","archived":false,"fork":false,"pushed_at":"2024-05-06T08:52:16.000Z","size":42,"stargazers_count":9,"open_issues_count":2,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-12T03:13:27.966Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bbqsrc.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-24T20:19:49.000Z","updated_at":"2024-06-25T14:45:45.000Z","dependencies_parsed_at":"2024-10-22T19:50:12.234Z","dependency_job_id":null,"html_url":"https://github.com/bbqsrc/eventlog","commit_stats":{"total_commits":45,"total_committers":4,"mean_commits":11.25,"dds":"0.28888888888888886","last_synced_commit":"1186dfec3d818e51543d5ecffb29477b885ee22a"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbqsrc%2Feventlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbqsrc%2Feventlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbqsrc%2Feventlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbqsrc%2Feventlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bbqsrc","download_url":"https://codeload.github.com/bbqsrc/eventlog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221665609,"owners_count":16860290,"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-11T03:13:27.172Z","updated_at":"2024-10-27T10:51:58.004Z","avatar_url":"https://github.com/bbqsrc.png","language":"Rust","readme":"# eventlog\n\n[![Latest version](https://img.shields.io/crates/v/eventlog.svg)](https://crates.io/crates/eventlog)\n[![Documentation](https://docs.rs/eventlog/badge.svg)](https://docs.rs/eventlog)\n\nA [log](https://docs.rs/log)-compatible wrapper around the [Windows Event Log API](https://docs.microsoft.com/en-us/windows/desktop/eventlog/event-logging).\n\nThanks to Jeroen C. van Gelderen for creating the [winlog](https://gitlab.com/arbitrix/winlog) project from which this is forked.\n\n## Features\n\n* Writes Rust log messages to the Windows event log using the\n  [RegisterEventSourceW](https://docs.microsoft.com/en-us/windows/desktop/api/Winbase/nf-winbase-registereventsourcew)\n  and [ReportEventW](https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-reporteventw) APIs.\n* Provides utility functions to register/unregister your\n  [event source](https://docs.microsoft.com/en-us/windows/desktop/eventlog/event-sources) in the Windows registry.\n* Embeds a small (120-byte) message resource library containing the necessary log message templates in your executable.\n* Does not panic.\n\nThe five Rust log levels are mapped to Windows [event types](https://docs.microsoft.com/en-us/windows/desktop/eventlog/event-types) as follows:\n\n| Rust Log Level | Windows Event Type | Windows Event Id |\n| -------------- | ------------------ | ---------------- |\n| Error          | Error              | 1                |\n| Warn           | Warning            | 2                |\n| Info           | Informational      | 3                |\n| Debug          | Informational      | 4                |\n| Trace          | Informational      | 5                |\n\n\n## Requirements\n\n* Rust 1.29+ on Windows with MSVC toolchain\n* [Windows, optional] [mc.exe](https://docs.microsoft.com/en-us/windows/desktop/wes/message-compiler--mc-exe-) and [rc.exe](https://docs.microsoft.com/en-us/windows/desktop/menurc/resource-compiler) (only required when `eventmsgs.mc` is changed)\n* [Windows, optional] PowerShell (used for the end-to-end test)\n\n## Usage\n\n### Cargo.toml\n\n```toml\n[dependencies]\neventlog = \"0.1.0\"\n```\n\n### Register log source with Windows\n\nRegister the log source in the Windows registry:\n```rust\neventlog::register(\"Example Log\").unwrap();\n```\n\nThis usually requires **Administrator** permission so this is usually done during installation time.\n\nIf your MSI installer (or similar) registers your event sources you should not call this.\n\n### Log events\n\n```rust\neventlog::init(\"Example Log\", log::Level::Trace).unwrap();\n\ninfo!(\"Hello, Event Log\");\ntrace!(\"This will be logged too\");\n```\n\n### Deregister log source\n\nDeregister the log source: \n\n```rust\neventlog::deregister(\"Example Log\").unwrap();\n```\n\nThis is usually done during program uninstallation. If your MSI installer (or similar) deregisters your event sources you should not call this.\n\n### Internals\n\nArtifacts `eventmsgs.lib` and `eventmsgs.rs` are under source control so users \ndon't need to have `mc.exe` and `rc.exe` installed for a standard build.\n\n1. If `build.rs` determines that `eventmsgs.mc` was changed then `build.rs`:\n   * invokes `mc.exe` (which creates `eventmsgs.h`)\n   * invokes `rc.exe` (which creates `eventmsgs.lib`)\n   * creates `eventmsgs.rs` from `eventmsgs.h`.\n2. `build.rs` emits linker flags so `eventmsgs.lib` can found.\n3. Standard `cargo build` follows.\n\n\n## Testing\n\nThe end-to-end test requires 'Full Control' permissions on the \n`HKLM\\SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application`\nregistry key.\n\n```rust\ncargo test\n```\n\n### Process:\n1. Create a unique temporary event source name (`eventlog-test-###########`).\n2. Register our compiled test executable as ```EventMessageFile``` for \n   the event source in the Windows registry. You can see a new key at \n   `HKLM\\SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\eventlog-test-###########`.\n2. Write some log messages to the event source.\n3. Use PowerShell to retrieve the logged messages.\n4. Deregister our event source. This removes the `eventlog-test-###########` \n   registry key.\n5. Assert that the retrieved log messages are correct. \n\n\n## License\n\nLicensed under either of\n\n* Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)\n* MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted \nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall \nbe dual licensed as above, without any additional terms or conditions.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbqsrc%2Feventlog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbbqsrc%2Feventlog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbqsrc%2Feventlog/lists"}