generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add debug logging #285
Open
diehuxx
wants to merge
17
commits into
main
Choose a base branch
from
debug-logging
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add debug logging #285
Changes from 5 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d7558e4
Add debug logging
diehuxx 523abec
PR comments
diehuxx 8e4f6f1
Lint
diehuxx 4c57d3c
Add commit hash to kotlin debug logging
diehuxx 065b97d
Merge branch 'main' into debug-logging
diehuxx e4155d7
Fix and test log_dbg
diehuxx e1aac22
Remove stuff I didnt mean to put there
diehuxx 0654617
Merge branch 'main' into debug-logging
diehuxx efa4310
Lint
diehuxx 0b11d23
Add back mod test_helpers
diehuxx 2af9bdd
Add web5_proc_macros with git_sha proc macro (#290)
KendallWeihe a349539
Build resources file with git SHA
diehuxx b76c675
Remove git hash from kotlin logger
diehuxx cfa3cc6
git ignore git sha resource
diehuxx 6c83a54
Remove git sha compiler flag
diehuxx d2a7d5b
Merge branch 'debug-logging-include-str' into debug-logging
diehuxx 6f28b1d
Use resource in log_dbg
diehuxx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use std::process::Command; | ||
|
||
fn main() { | ||
// Execute the `git rev-parse HEAD` command to get the current commit hash | ||
let output = Command::new("git") | ||
.args(["rev-parse", "HEAD"]) | ||
.output() | ||
.expect("Failed to execute git command"); | ||
|
||
// Convert the output to a string | ||
let git_hash = String::from_utf8(output.stdout).expect("Invalid UTF-8 sequence"); | ||
|
||
// Remove the newline character from the commit hash | ||
let git_hash_trimmed = git_hash.trim(); | ||
|
||
// Pass the commit hash to the compiler as an environment variable | ||
println!("cargo:rustc-env=WEB5_GIT_COMMIT_HASH={}", git_hash_trimmed); | ||
KendallWeihe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,30 @@ pub mod dids; | |
|
||
#[cfg(test)] | ||
mod test_helpers; | ||
|
||
lazy_static::lazy_static! { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Upd8d |
||
pub(crate) static ref LOG_LEVEL: Option<String> = { | ||
std::env::var("WEB5_SDK_LOG_LEVEL").ok() | ||
}; | ||
} | ||
|
||
pub(crate) mod logging { | ||
KendallWeihe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#[macro_export] | ||
macro_rules! log_dbg { | ||
($msg:expr, $($arg:tt)*) => { | ||
if let Some(ref level) = *$crate::LOG_LEVEL { | ||
if level == "DEBUG" { | ||
println!("[DEBUG] {}:{}", env!("GIT_COMMIT_HASH"), format!($msg, $($arg)*)); | ||
} | ||
} | ||
}; | ||
($closure:expr) => { | ||
if let Some(ref level) = *$crate::LOG_LEVEL { | ||
if level == "DEBUG" { | ||
let msg = $closure(); | ||
println!("[DEBUG] {}:{}", env!("GIT_COMMIT_HASH"), msg); | ||
} | ||
} | ||
}; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we update the Justfile to 1.80.0 and use the new LazyLock? I'm doing that over here https://github.com/TBD54566975/web5-rs/pull/283/files#diff-8b2fda406bc73cf365197448d20bd9ea1d05db17e9b8dca69881ad9dd9755f5d (scroll down to the tests)