Skip to content

enable tracing and add tracing types and func #730

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

Merged
merged 2 commits into from
Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libgit2-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ fn main() {
features.push_str("#ifndef INCLUDE_features_h\n");
features.push_str("#define INCLUDE_features_h\n");
features.push_str("#define GIT_THREADS 1\n");
features.push_str("#define GIT_TRACE 1\n");

if !target.contains("android") {
features.push_str("#define GIT_USE_NSEC 1\n");
Expand Down
29 changes: 29 additions & 0 deletions libgit2-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1892,6 +1892,33 @@ pub const GIT_WORKTREE_PRUNE_OPTIONS_VERSION: c_uint = 1;
pub type git_repository_mergehead_foreach_cb =
Option<extern "C" fn(oid: *const git_oid, payload: *mut c_void) -> c_int>;

git_enum! {
pub enum git_trace_level_t {
/* No tracing will be performed. */
GIT_TRACE_NONE = 0,

/* Severe errors that may impact the program's execution */
GIT_TRACE_FATAL = 1,

/* Errors that do not impact the program's execution */
GIT_TRACE_ERROR = 2,

/* Warnings that suggest abnormal data */
GIT_TRACE_WARN = 3,

/* Informational messages about program execution */
GIT_TRACE_INFO = 4,

/* Detailed data that allows for debugging */
GIT_TRACE_DEBUG = 5,

/* Exceptionally detailed debugging data */
GIT_TRACE_TRACE = 6,
}
}

pub type git_trace_cb = Option<extern "C" fn(level: git_trace_level_t, msg: *const c_char)>;

extern "C" {
// threads
pub fn git_libgit2_init() -> c_int;
Expand Down Expand Up @@ -3986,6 +4013,8 @@ extern "C" {
replace_name: *const c_char,
replace_email: *const c_char,
) -> c_int;

pub fn git_trace_set(level: git_trace_level_t, cb: git_trace_cb) -> c_int;
}

pub fn init() {
Expand Down