Import kv-log-macro 1.0.7 upstream upstream/1.0.7
authorDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 13 Mar 2023 05:37:49 +0000 (14:37 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 13 Mar 2023 05:37:49 +0000 (14:37 +0900)
20 files changed:
.cargo_vcs_info.json [new file with mode: 0644]
.github/CODE_OF_CONDUCT.md [new file with mode: 0644]
.github/CONTRIBUTING.md [new file with mode: 0644]
.github/ISSUE_TEMPLATE.md [new file with mode: 0644]
.github/ISSUE_TEMPLATE/bug_report.md [new file with mode: 0644]
.github/ISSUE_TEMPLATE/feature_request.md [new file with mode: 0644]
.github/ISSUE_TEMPLATE/question.md [new file with mode: 0644]
.github/PULL_REQUEST_TEMPLATE.md [new file with mode: 0644]
.github/stale.yml [new file with mode: 0644]
.gitignore [new file with mode: 0644]
.travis.yml [new file with mode: 0644]
CHANGELOG.md [new file with mode: 0644]
Cargo.toml [new file with mode: 0644]
Cargo.toml.orig [new file with mode: 0644]
LICENSE-APACHE [new file with mode: 0644]
LICENSE-MIT [new file with mode: 0644]
README.md [new file with mode: 0644]
examples/main.rs [new file with mode: 0644]
src/lib.rs [new file with mode: 0644]
tests/test.rs [new file with mode: 0644]

diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
new file mode 100644 (file)
index 0000000..7038263
--- /dev/null
@@ -0,0 +1,5 @@
+{
+  "git": {
+    "sha1": "b1ec3d2194835a83146d7b720203b5f9c731bc58"
+  }
+}
diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md
new file mode 100644 (file)
index 0000000..3b6645e
--- /dev/null
@@ -0,0 +1,75 @@
+# Contributor Covenant Code of Conduct\r
+\r
+## Our Pledge\r
+\r
+In the interest of fostering an open and welcoming environment, we as\r
+contributors and maintainers pledge to making participation in our project and\r
+our community a harassment-free experience for everyone, regardless of age, body\r
+size, disability, ethnicity, gender identity and expression, level of\r
+experience,\r
+education, socio-economic status, nationality, personal appearance, race,\r
+religion, or sexual identity and orientation.\r
+\r
+## Our Standards\r
+\r
+Examples of behavior that contributes to creating a positive environment\r
+include:\r
+\r
+- Using welcoming and inclusive language\r
+- Being respectful of differing viewpoints and experiences\r
+- Gracefully accepting constructive criticism\r
+- Focusing on what is best for the community\r
+- Showing empathy towards other community members\r
+\r
+Examples of unacceptable behavior by participants include:\r
+\r
+- The use of sexualized language or imagery and unwelcome sexual attention or\r
+advances\r
+- Trolling, insulting/derogatory comments, and personal or political attacks\r
+- Public or private harassment\r
+- Publishing others' private information, such as a physical or electronic\r
+address, without explicit permission\r
+- Other conduct which could reasonably be considered inappropriate in a\r
+professional setting\r
+\r
+\r
+## Our Responsibilities\r
+\r
+Project maintainers are responsible for clarifying the standards of acceptable\r
+behavior and are expected to take appropriate and fair corrective action in\r
+response to any instances of unacceptable behavior.\r
+\r
+Project maintainers have the right and responsibility to remove, edit, or\r
+reject comments, commits, code, wiki edits, issues, and other contributions\r
+that are not aligned to this Code of Conduct, or to ban temporarily or\r
+permanently any contributor for other behaviors that they deem inappropriate,\r
+threatening, offensive, or harmful.\r
+\r
+## Scope\r
+\r
+This Code of Conduct applies both within project spaces and in public spaces\r
+when an individual is representing the project or its community. Examples of\r
+representing a project or community include using an official project e-mail\r
+address, posting via an official social media account, or acting as an appointed\r
+representative at an online or offline event. Representation of a project may be\r
+further defined and clarified by project maintainers.\r
+\r
+## Enforcement\r
+\r
+Instances of abusive, harassing, or otherwise unacceptable behavior may be\r
+reported by contacting the project team at yoshuawuyts@gmail.com, or through\r
+IRC. All complaints will be reviewed and investigated and will result in a\r
+response that is deemed necessary and appropriate to the circumstances. The\r
+project team is obligated to maintain confidentiality with regard to the\r
+reporter of an incident.\r
+Further details of specific enforcement policies may be posted separately.\r
+\r
+Project maintainers who do not follow or enforce the Code of Conduct in good\r
+faith may face temporary or permanent repercussions as determined by other\r
+members of the project's leadership.\r
+\r
+## Attribution\r
+\r
+This Code of Conduct is adapted from the Contributor Covenant, version 1.4,\r
+available at\r
+https://www.contributor-covenant.org/version/1/4/code-of-conduct.html\r
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
new file mode 100644 (file)
index 0000000..9650c09
--- /dev/null
@@ -0,0 +1,55 @@
+# Contributing\r
+Contributions include code, documentation, answering user questions, running the\r
+project's infrastructure, and advocating for all types of users.\r
+\r
+The project welcomes all contributions from anyone willing to work in good faith\r
+with other contributors and the community. No contribution is too small and all\r
+contributions are valued.\r
+\r
+This guide explains the process for contributing to the project's GitHub\r
+Repository.\r
+\r
+- [Code of Conduct](#code-of-conduct)\r
+- [Bad Actors](#bad-actors)\r
+\r
+## Code of Conduct\r
+The project has a [Code of Conduct](./CODE_OF_CONDUCT.md) that *all*\r
+contributors are expected to follow. This code describes the *minimum* behavior\r
+expectations for all contributors.\r
+\r
+As a contributor, how you choose to act and interact towards your\r
+fellow contributors, as well as to the community, will reflect back not only\r
+on yourself but on the project as a whole. The Code of Conduct is designed and\r
+intended, above all else, to help establish a culture within the project that\r
+allows anyone and everyone who wants to contribute to feel safe doing so.\r
+\r
+Should any individual act in any way that is considered in violation of the\r
+[Code of Conduct](./CODE_OF_CONDUCT.md), corrective actions will be taken. It is\r
+possible, however, for any individual to *act* in such a manner that is not in\r
+violation of the strict letter of the Code of Conduct guidelines while still\r
+going completely against the spirit of what that Code is intended to accomplish.\r
+\r
+Open, diverse, and inclusive communities live and die on the basis of trust.\r
+Contributors can disagree with one another so long as they trust that those\r
+disagreements are in good faith and everyone is working towards a common\r
+goal.\r
+\r
+## Bad Actors\r
+All contributors to tacitly agree to abide by both the letter and\r
+spirit of the [Code of Conduct](./CODE_OF_CONDUCT.md). Failure, or\r
+unwillingness, to do so will result in contributions being respectfully\r
+declined.\r
+\r
+A *bad actor* is someone who repeatedly violates the *spirit* of the Code of\r
+Conduct through consistent failure to self-regulate the way in which they\r
+interact with other contributors in the project. In doing so, bad actors\r
+alienate other contributors, discourage collaboration, and generally reflect\r
+poorly on the project as a whole.\r
+\r
+Being a bad actor may be intentional or unintentional. Typically, unintentional\r
+bad behavior can be easily corrected by being quick to apologize and correct\r
+course *even if you are not entirely convinced you need to*. Giving other\r
+contributors the benefit of the doubt and having a sincere willingness to admit\r
+that you *might* be wrong is critical for any successful open collaboration.\r
+\r
+Don't be a bad actor.\r
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
new file mode 100644 (file)
index 0000000..8d1cbf0
--- /dev/null
@@ -0,0 +1,9 @@
+## Summary\r
+Explain what is going on.\r
+\r
+## Your Environment\r
+| Software         | Version(s) |\r
+| ---------------- | ---------- |\r
+| kv-log-macro      |\r
+| Rustc            |\r
+| Operating System |\r
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644 (file)
index 0000000..3327a38
--- /dev/null
@@ -0,0 +1,23 @@
+---\r
+name: Bug Report\r
+about: Did something not work as expected?\r
+---\r
+\r
+# Bug Report\r
+## Your Environment\r
+| Software         | Version(s) |\r
+| ---------------- | ---------- |\r
+| kv-log-macro      |\r
+| Rustc            |\r
+| Operating System |\r
+\r
+## Expected Behavior\r
+Tell us what should have happened.\r
+\r
+## Current Behavior\r
+Tell us what happens instead of the expected behavior. If you are seeing an\r
+error, please include the full error message and stack trace.\r
+\r
+## Code Sample\r
+Please provide a code repository, gist, code snippet or sample files to\r
+reproduce the issue.\r
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644 (file)
index 0000000..1dbfb27
--- /dev/null
@@ -0,0 +1,43 @@
+---\r
+name: Feature Request\r
+about: Want us to add something to kv-log-macro?\r
+---\r
+\r
+# Feature Request\r
+## Summary\r
+One paragraph explanation of the feature.\r
+\r
+## Motivation\r
+Why are we doing this? What use cases does it support? What is the expected\r
+outcome?\r
+\r
+## Guide-level explanation\r
+Explain the proposal as if it was already included in the project and you\r
+were teaching it to another programmer. That generally means:\r
+\r
+- Introducing new named concepts.\r
+- Explaining the feature largely in terms of examples.\r
+- If applicable, provide sample error messages, deprecation warnings, or\r
+  migration guidance.\r
+\r
+## Reference-level explanation\r
+This is the technical portion of the feature request. Explain the design in\r
+sufficient detail that:\r
+\r
+- Its interaction with other features is clear.\r
+- It is reasonably clear how the feature would be implemented.\r
+- Corner cases are dissected by example.\r
+\r
+## Drawbacks\r
+Why should we _not_ do this?\r
+\r
+## Rationale and alternatives\r
+- Why is this design the best in the space of possible designs?\r
+- What other designs have been considered and what is the rationale for not\r
+  choosing them?\r
+- What is the impact of not doing this?\r
+\r
+## Unresolved Questions\r
+What related issues do you consider out of scope for this feature that could be\r
+addressed in the future independently of the solution that comes out of this\r
+feature?\r
diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md
new file mode 100644 (file)
index 0000000..2023e5d
--- /dev/null
@@ -0,0 +1,18 @@
+---\r
+name: Question\r
+about: Have any questions regarding how kv-log-macro works?\r
+---\r
+\r
+# Question\r
+## Your Environment\r
+| Software         | Version(s) |\r
+| ---------------- | ---------- |\r
+| kv-log-macro      |\r
+| Rustc            |\r
+| Operating System |\r
+\r
+## Question\r
+Provide your question here.\r
+\r
+## Context\r
+How has this issue affected you? What are you trying to accomplish?\r
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644 (file)
index 0000000..f714d6e
--- /dev/null
@@ -0,0 +1,14 @@
+<!--- Provide a general summary of your changes in the Title above -->\r
+\r
+## Description\r
+<!--- Describe your changes in detail -->\r
+\r
+## Motivation and Context\r
+<!--- Why is this change required? What problem does it solve? -->\r
+<!--- If it fixes an open issue, please link to the issue here. -->\r
+\r
+## Types of changes\r
+<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->\r
+- [ ] Bug fix (non-breaking change which fixes an issue)\r
+- [ ] New feature (non-breaking change which adds functionality)\r
+- [ ] Breaking change (fix or feature that would cause existing functionality to change)\r
diff --git a/.github/stale.yml b/.github/stale.yml
new file mode 100644 (file)
index 0000000..60f4c1a
--- /dev/null
@@ -0,0 +1,17 @@
+# Configuration for probot-stale - https://github.com/probot/stale\r
+\r
+daysUntilStale: 90\r
+daysUntilClose: 7\r
+exemptLabels:\r
+  - pinned\r
+  - security\r
+exemptProjects: false\r
+exemptMilestones: false\r
+staleLabel: wontfix\r
+markComment: >\r
+  This issue has been automatically marked as stale because it has not had\r
+  recent activity. It will be closed if no further activity occurs. Thank you\r
+  for your contributions.\r
+unmarkComment: false\r
+closeComment: false\r
+limitPerRun: 30\r
diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..209dbac
--- /dev/null
@@ -0,0 +1,7 @@
+coverage/\r
+target/\r
+tmp/\r
+dist/\r
+npm-debug.log*\r
+Cargo.lock\r
+.DS_Store\r
diff --git a/.travis.yml b/.travis.yml
new file mode 100644 (file)
index 0000000..a9eb401
--- /dev/null
@@ -0,0 +1,13 @@
+language: rust\r
+rust:\r
+  - stable\r
+\r
+before_script: |\r
+  rustup component add rustfmt-preview &&\r
+  rustup component add clippy-preview\r
+script: |\r
+  cargo fmt -- --check &&\r
+  cargo clippy -- -D clippy &&\r
+  cargo build --verbose &&\r
+  cargo test  --verbose\r
+cache: cargo\r
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644 (file)
index 0000000..bf3c6d6
--- /dev/null
@@ -0,0 +1,54 @@
+## 2019-09-01, Version 1.0.4\r
+### Commits\r
+- [[`9c938867f5`](https://github.com/yoshuawuyts/kv-log-macro/commit/9c938867f56dd7ec4642301e726493967f5057a3)] (cargo-release) version 1.0.4 (Yoshua Wuyts)\r
+- [[`4d1cd07382`](https://github.com/yoshuawuyts/kv-log-macro/commit/4d1cd0738248dfe73aab97f04c8c741593e32ad6)] use ToValue as the bound for captured values (#1) (Ashley Mannix)\r
+- [[`7cc2af3db3`](https://github.com/yoshuawuyts/kv-log-macro/commit/7cc2af3db316f1849cd06a810ab5b5285f864e88)] Update changelog (Yoshua Wuyts)\r
+\r
+### Stats\r
+```diff\r
+ CHANGELOG.md     | 38 ++++++++++++++++++++++++++++++++++++++\r
+ Cargo.toml       |  2 +-\r
+ examples/main.rs |  1 +\r
+ src/lib.rs       | 31 ++-----------------------------\r
+ 4 files changed, 42 insertions(+), 30 deletions(-)\r
+```\r
+\r
+\r
+## 2019-09-01, Version 1.0.3\r
+### Commits\r
+- [[`5179f8418a`](https://github.com/yoshuawuyts/kv-log-macro/commit/5179f8418aee109e2131034d2d8675944ec8ca38)] (cargo-release) version 1.0.3 (Yoshua Wuyts)\r
+- [[`ed25f609fe`](https://github.com/yoshuawuyts/kv-log-macro/commit/ed25f609fe17b3814c5dfd6801ca4b2ddd356dac)] fix lvl (Yoshua Wuyts)\r
+- [[`7ed93d55f6`](https://github.com/yoshuawuyts/kv-log-macro/commit/7ed93d55f62aee83a08d62f7a72da32de94c019c)] (cargo-release) version 1.0.2 (Yoshua Wuyts)\r
+- [[`751336f2b1`](https://github.com/yoshuawuyts/kv-log-macro/commit/751336f2b17e5989c4378fd38a25d3c937930741)] fix log feat (Yoshua Wuyts)\r
+- [[`21acf4fc36`](https://github.com/yoshuawuyts/kv-log-macro/commit/21acf4fc363ac44223ebeed95fcbdbd6fb1f53f7)] (cargo-release) version 1.0.1 (Yoshua Wuyts)\r
+- [[`51961f3281`](https://github.com/yoshuawuyts/kv-log-macro/commit/51961f3281314d1a570003f1dc1b0eecc83d5568)] lib.rs example (Yoshua Wuyts)\r
+- [[`fa8a68e00d`](https://github.com/yoshuawuyts/kv-log-macro/commit/fa8a68e00d1cbaab9439e71517d4d8eedeac23ae)] keywords (Yoshua Wuyts)\r
+- [[`a5b1ec57c3`](https://github.com/yoshuawuyts/kv-log-macro/commit/a5b1ec57c3939e17d1d37547aaaaf666ba04abff)] readme (Yoshua Wuyts)\r
+- [[`d6b1429476`](https://github.com/yoshuawuyts/kv-log-macro/commit/d6b1429476b1af71eabdac530eaaaf9b5726d864)] finish impls (Yoshua Wuyts)\r
+- [[`1020528531`](https://github.com/yoshuawuyts/kv-log-macro/commit/102052853137386912f3caedf7da4fb0ee2548ae)] done! (Yoshua Wuyts)\r
+- [[`8a398d49a6`](https://github.com/yoshuawuyts/kv-log-macro/commit/8a398d49a6d111dbe9f3145ba9b52d4a158218e0)] key values work! (Yoshua Wuyts)\r
+- [[`48b01120de`](https://github.com/yoshuawuyts/kv-log-macro/commit/48b01120de73c5dbc1847e77df286e1a6f3bd9f1)] . (Yoshua Wuyts)\r
+\r
+### Stats\r
+```diff\r
+ .github/CODE_OF_CONDUCT.md                |  75 +++++++++-\r
+ .github/CONTRIBUTING.md                   |  55 ++++++-\r
+ .github/ISSUE_TEMPLATE.md                 |   9 +-\r
+ .github/ISSUE_TEMPLATE/bug_report.md      |  23 +++-\r
+ .github/ISSUE_TEMPLATE/feature_request.md |  43 +++++-\r
+ .github/ISSUE_TEMPLATE/question.md        |  18 ++-\r
+ .github/PULL_REQUEST_TEMPLATE.md          |  14 ++-\r
+ .github/stale.yml                         |  17 ++-\r
+ .gitignore                                |   7 +-\r
+ .travis.yml                               |  13 +-\r
+ Cargo.toml                                |  18 ++-\r
+ LICENSE-APACHE                            | 190 ++++++++++++++++++++++-\r
+ LICENSE-MIT                               |  21 ++-\r
+ README.md                                 |  62 +++++++-\r
+ examples/main.rs                          |  13 +-\r
+ src/lib.rs                                | 272 +++++++++++++++++++++++++++++++-\r
+ tests/test.rs                             |   6 +-\r
+ 17 files changed, 856 insertions(+)\r
+```\r
+\r
+\r
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644 (file)
index 0000000..f971c82
--- /dev/null
@@ -0,0 +1,29 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g., crates.io) dependencies
+#
+# If you believe there's an error in this file please file an
+# issue against the rust-lang/cargo repository. If you're
+# editing this file be aware that the upstream Cargo.toml
+# will likely look very different (and much more reasonable)
+
+[package]
+edition = "2018"
+name = "kv-log-macro"
+version = "1.0.7"
+authors = ["Yoshua Wuyts <yoshuawuyts@gmail.com>"]
+description = "Log macro for log's kv-unstable backend."
+documentation = "https://docs.rs/kv-log-macro"
+readme = "README.md"
+keywords = ["log", "macro", "kv", "key", "value"]
+categories = ["text-processing"]
+license = "MIT OR Apache-2.0"
+repository = "https://github.com/yoshuawuyts/kv-log-macro"
+[dependencies.log]
+version = "0.4.8"
+features = ["kv_unstable"]
+[dev-dependencies.femme]
+version = "1.2.0"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
new file mode 100644 (file)
index 0000000..f5b3961
--- /dev/null
@@ -0,0 +1,18 @@
+[package]\r
+name = "kv-log-macro"\r
+version = "1.0.7"\r
+license = "MIT OR Apache-2.0"\r
+repository = "https://github.com/yoshuawuyts/kv-log-macro"\r
+documentation = "https://docs.rs/kv-log-macro"\r
+description = "Log macro for log's kv-unstable backend."\r
+keywords = ["log", "macro", "kv", "key", "value"]\r
+categories = ["text-processing"]\r
+authors = ["Yoshua Wuyts <yoshuawuyts@gmail.com>"]\r
+readme = "README.md"\r
+edition = "2018"\r
+\r
+[dependencies]\r
+log = { version = "0.4.8", features = ["kv_unstable"] }\r
+\r
+[dev-dependencies]\r
+femme = "1.2.0"\r
diff --git a/LICENSE-APACHE b/LICENSE-APACHE
new file mode 100644 (file)
index 0000000..388f79a
--- /dev/null
@@ -0,0 +1,190 @@
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   Copyright 2019 Yoshua Wuyts\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
diff --git a/LICENSE-MIT b/LICENSE-MIT
new file mode 100644 (file)
index 0000000..f26563c
--- /dev/null
@@ -0,0 +1,21 @@
+The MIT License (MIT)\r
+\r
+Copyright (c) 2019 Yoshua Wuyts\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a copy\r
+of this software and associated documentation files (the "Software"), to deal\r
+in the Software without restriction, including without limitation the rights\r
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
+copies of the Software, and to permit persons to whom the Software is\r
+furnished to do so, subject to the following conditions:\r
+\r
+The above copyright notice and this permission notice shall be included in all\r
+copies or substantial portions of the Software.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+SOFTWARE.\r
diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..14c702c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,62 @@
+# kv-log-macro\r
+[![crates.io version][1]][2] [![build status][3]][4]\r
+[![downloads][5]][6] [![docs.rs docs][7]][8]\r
+\r
+Log macro for log's kv-unstable backend.\r
+\r
+- [Documentation][8]\r
+- [Crates.io][2]\r
+- [Releases][releases]\r
+\r
+## Examples\r
+```rust\r
+use kv_log_macro::info;\r
+\r
+fn main() {\r
+    femme::start(log::LevelFilter::Info).unwrap();\r
+    info!("hello");\r
+    info!("hello",);\r
+    info!("hello {}", "cats");\r
+    info!("hello {}", "cats",);\r
+    info!("hello {}", "cats", {\r
+        cat_1: "chashu",\r
+        cat_2: "nori",\r
+    });\r
+}\r
+```\r
+\r
+## Installation\r
+```sh\r
+$ cargo add kv-log-macro\r
+```\r
+\r
+## Safety\r
+This crate uses ``#![deny(unsafe_code)]`` to ensure everything is implemented in\r
+100% Safe Rust.\r
+\r
+## Contributing\r
+Want to join us? Check out our ["Contributing" guide][contributing] and take a\r
+look at some of these issues:\r
+\r
+- [Issues labeled "good first issue"][good-first-issue]\r
+- [Issues labeled "help wanted"][help-wanted]\r
+\r
+## References\r
+None.\r
+\r
+## License\r
+[MIT](./LICENSE-MIT) OR [Apache-2.0](./LICENSE-APACHE)\r
+\r
+[1]: https://img.shields.io/crates/v/kv-log-macro.svg?style=flat-square\r
+[2]: https://crates.io/crates/kv-log-macro\r
+[3]: https://img.shields.io/travis/yoshuawuyts/kv-log-macro/master.svg?style=flat-square\r
+[4]: https://travis-ci.org/yoshuawuyts/kv-log-macro\r
+[5]: https://img.shields.io/crates/d/kv-log-macro.svg?style=flat-square\r
+[6]: https://crates.io/crates/kv-log-macro\r
+[7]: https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square\r
+[8]: https://docs.rs/kv-log-macro\r
+\r
+[releases]: https://github.com/yoshuawuyts/kv-log-macro/releases\r
+[contributing]: https://github.com/yoshuawuyts/kv-log-macro/blob/master.github/CONTRIBUTING.md\r
+[good-first-issue]: https://github.com/yoshuawuyts/kv-log-macro/labels/good%20first%20issue\r
+[help-wanted]: https://github.com/yoshuawuyts/kv-log-macro/labels/help%20wanted\r
diff --git a/examples/main.rs b/examples/main.rs
new file mode 100644 (file)
index 0000000..e5aae0a
--- /dev/null
@@ -0,0 +1,14 @@
+use kv_log_macro::info;\r
+\r
+fn main() {\r
+    femme::start(log::LevelFilter::Info).unwrap();\r
+    info!("hello");\r
+    info!("hello",);\r
+    info!("hello {}", "cats");\r
+    info!("hello {}", "cats",);\r
+    info!("hello {}", "cats", {\r
+        cat_1: "chashu",\r
+        cat_2: "nori",\r
+        cat_count: 2,\r
+    });\r
+}\r
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644 (file)
index 0000000..1d1a15c
--- /dev/null
@@ -0,0 +1,244 @@
+//! Log macro for log's kv-unstable backend.\r
+//!\r
+//! ## Example\r
+//!\r
+//! ```rust\r
+//! use kv_log_macro::info;\r
+//!\r
+//! femme::start(log::LevelFilter::Info).unwrap();\r
+//!\r
+//! info!("hello");\r
+//! info!("hello",);\r
+//! info!("hello {}", "cats");\r
+//! info!("hello {}", "cats",);\r
+//! info!("hello {}", "cats", {\r
+//!     cat_1: "chashu",\r
+//!     cat_2: "nori",\r
+//! });\r
+//! ```\r
+\r
+#![forbid(unsafe_code, future_incompatible, rust_2018_idioms)]\r
+#![deny(missing_debug_implementations, nonstandard_style)]\r
+#![warn(missing_docs, missing_doc_code_examples, unreachable_pub)]\r
+// #![cfg_attr(test, deny(warnings))]\r
+\r
+use log::{logger, LevelFilter, Record};\r
+\r
+use std::fmt;\r
+\r
+// publicly exporting so $crate::Level works.\r
+pub use log::Level;\r
+\r
+/// The statically resolved maximum log level.\r
+pub const STATIC_MAX_LEVEL: LevelFilter = log::STATIC_MAX_LEVEL;\r
+\r
+/// Returns the current maximum log level.\r
+#[inline]\r
+pub fn max_level() -> LevelFilter {\r
+    log::max_level()\r
+}\r
+\r
+/// The standard logging macro.\r
+///\r
+/// ```\r
+/// use kv_log_macro::info;\r
+///\r
+/// info!("hello");\r
+/// info!("hello",);\r
+/// info!("hello {}", "cats");\r
+/// info!("hello {}", "cats",);\r
+/// info!("hello {}", "cats", {\r
+///     cat_1: "chashu",\r
+///     cat_2: "nori",\r
+/// });\r
+/// ```\r
+#[macro_export(local_inner_macros)]\r
+macro_rules! log {\r
+    // log!(target: "...", "...")\r
+    (target: $target:expr, $lvl:expr, $e:expr) => {\r
+        $crate::log_impl!(target: $target, $lvl, ($e));\r
+    };\r
+\r
+    // log!(target: "...", "...", args...)\r
+    (target: $target:expr, $lvl:expr, $e:expr, $($rest:tt)*) => {\r
+        $crate::log_impl!(target: $target, $lvl, ($e) $($rest)*);\r
+    };\r
+\r
+    // log!("...", args...)\r
+    ($lvl:expr, $($arg:tt)+) => ($crate::log!(target: __log_module_path!(), $lvl, $($arg)+))\r
+}\r
+\r
+#[macro_export(local_inner_macros)]\r
+#[doc(hidden)]\r
+macro_rules! log_impl {\r
+    // End of macro input\r
+    (target: $target:expr, $lvl:expr, ($($arg:expr),*)) => {{\r
+        let lvl = $lvl;\r
+        if lvl <= $crate::STATIC_MAX_LEVEL && lvl <= $crate::max_level() {\r
+            $crate::__private_api_log(\r
+                __log_format_args!($($arg),*),\r
+                lvl,\r
+                &($target, __log_module_path!(), __log_file!(), __log_line!()),\r
+                None,\r
+            );\r
+        }\r
+    }};\r
+\r
+    // // Trailing k-v pairs containing no trailing comma\r
+    (target: $target:expr, $lvl:expr, ($($arg:expr),*) { $($key:ident : $value:expr),* }) => {{\r
+        if $lvl <= $crate::STATIC_MAX_LEVEL && $lvl <= $crate::max_level() {\r
+            $crate::__private_api_log(\r
+                __log_format_args!($($arg),*),\r
+                $lvl,\r
+                &(__log_module_path!(), __log_module_path!(), __log_file!(), __log_line!()),\r
+                Some(&[$((__log_stringify!($key), &$value)),*])\r
+            );\r
+        }\r
+    }};\r
+\r
+    // Trailing k-v pairs with trailing comma\r
+    (target: $target:expr, $lvl:expr, ($($e:expr),*) { $($key:ident : $value:expr,)* }) => {\r
+        $crate::log_impl!(target: $target, $lvl, ($($e),*) { $($key : $value),* });\r
+    };\r
+\r
+    // Last expression arg with no trailing comma\r
+    (target: $target:expr, $lvl:expr, ($($e:expr),*) $arg:expr) => {\r
+        $crate::log_impl!(target: $target, $lvl, ($($e,)* $arg));\r
+    };\r
+\r
+    // Expression arg\r
+    (target: $target:expr, $lvl:expr, ($($e:expr),*) $arg:expr, $($rest:tt)*) => {\r
+        $crate::log_impl!(target: $target, $lvl, ($($e,)* $arg) $($rest)*);\r
+    };\r
+}\r
+\r
+/// Logs a message at the trace level.\r
+#[macro_export(local_inner_macros)]\r
+macro_rules! trace {\r
+    (target: $target:expr, $($arg:tt)+) => (\r
+        log!(target: $target, $crate::Level::Trace, $($arg)+);\r
+    );\r
+    ($($arg:tt)+) => (\r
+        log!($crate::Level::Trace, $($arg)+);\r
+    )\r
+}\r
+\r
+/// Logs a message at the debug level.\r
+#[macro_export(local_inner_macros)]\r
+macro_rules! debug {\r
+    (target: $target:expr, $($arg:tt)+) => (\r
+        log!(target: $target, $crate::Level::Debug, $($arg)+);\r
+    );\r
+    ($($arg:tt)+) => (\r
+        log!($crate::Level::Debug, $($arg)+);\r
+    )\r
+}\r
+\r
+/// Logs a message at the info level.\r
+#[macro_export(local_inner_macros)]\r
+macro_rules! info {\r
+    (target: $target:expr, $($arg:tt)+) => (\r
+        log!(target: $target, $crate::Level::Info, $($arg)+);\r
+    );\r
+    ($($arg:tt)+) => (\r
+        log!($crate::Level::Info, $($arg)+);\r
+    )\r
+}\r
+\r
+/// Logs a message at the warn level.\r
+#[macro_export(local_inner_macros)]\r
+macro_rules! warn {\r
+    (target: $target:expr, $($arg:tt)+) => (\r
+        log!(target: $target, $crate::Level::Warn, $($arg)+);\r
+    );\r
+    ($($arg:tt)+) => (\r
+        log!($crate::Level::Warn, $($arg)+);\r
+    )\r
+}\r
+\r
+/// Logs a message at the error level.\r
+#[macro_export(local_inner_macros)]\r
+macro_rules! error {\r
+    (target: $target:expr, $($arg:tt)+) => (\r
+        log!(target: $target, $crate::Level::Error, $($arg)+);\r
+    );\r
+    ($($arg:tt)+) => (\r
+        log!($crate::Level::Error, $($arg)+);\r
+    )\r
+}\r
+\r
+/// Determines if a message logged at the specified level in that module will\r
+/// be logged.\r
+#[macro_export(local_inner_macros)]\r
+macro_rules! log_enabled {\r
+    (target: $target:expr, $lvl:expr) => {{\r
+        let lvl = $lvl;\r
+        lvl <= $crate::STATIC_MAX_LEVEL\r
+            && lvl <= $crate::max_level()\r
+            && $crate::__private_api_enabled(lvl, $target)\r
+    }};\r
+    ($lvl:expr) => {\r
+        log_enabled!(target: __log_module_path!(), $lvl)\r
+    };\r
+}\r
+\r
+#[doc(hidden)]\r
+#[macro_export]\r
+macro_rules! __log_format_args {\r
+    ($($args:tt)*) => {\r
+        format_args!($($args)*)\r
+    };\r
+}\r
+\r
+#[doc(hidden)]\r
+#[macro_export]\r
+macro_rules! __log_module_path {\r
+    () => {\r
+        module_path!()\r
+    };\r
+}\r
+\r
+#[doc(hidden)]\r
+#[macro_export]\r
+macro_rules! __log_file {\r
+    () => {\r
+        file!()\r
+    };\r
+}\r
+\r
+#[doc(hidden)]\r
+#[macro_export]\r
+macro_rules! __log_line {\r
+    () => {\r
+        line!()\r
+    };\r
+}\r
+\r
+#[doc(hidden)]\r
+#[macro_export]\r
+macro_rules! __log_stringify {\r
+    ($($args:tt)*) => {\r
+        stringify!($($args)*)\r
+    };\r
+}\r
+\r
+// WARNING: this is not part of the crate's public API and is subject to change at any time\r
+#[doc(hidden)]\r
+pub fn __private_api_log(\r
+    args: fmt::Arguments<'_>,\r
+    level: Level,\r
+    &(target, module_path, file, line): &(&str, &'static str, &'static str, u32),\r
+    kvs: Option<&[(&str, &dyn log::kv::ToValue)]>,\r
+) {\r
+    logger().log(\r
+        &Record::builder()\r
+            .args(args)\r
+            .level(level)\r
+            .target(target)\r
+            .module_path_static(Some(module_path))\r
+            .file_static(Some(file))\r
+            .line(Some(line))\r
+            .key_values(&kvs)\r
+            .build(),\r
+    );\r
+}\r
diff --git a/tests/test.rs b/tests/test.rs
new file mode 100644 (file)
index 0000000..9aa2400
--- /dev/null
@@ -0,0 +1,6 @@
+use std::error::Error;\r
+\r
+#[test]\r
+fn should_work() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {\r
+    Ok(())\r
+}\r