summaryrefslogtreecommitdiff
path: root/src/trace.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2013-03-04 23:52:30 -0600
committerEdward Thomson <ethomson@edwardthomson.com>2013-03-07 12:42:33 -0600
commitb5ec5430a8cad68c1c534568a5a7047e42f75580 (patch)
tree1b2fa272f72c795cbfda61c93c18abb014be6c2b /src/trace.c
parent6a9ef012376e8a21dcfd0499ab16048eb6e954c3 (diff)
downloadlibgit2-b5ec5430a8cad68c1c534568a5a7047e42f75580.tar.gz
optional tracing
Diffstat (limited to 'src/trace.c')
-rw-r--r--src/trace.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/trace.c b/src/trace.c
new file mode 100644
index 000000000..159ac91cc
--- /dev/null
+++ b/src/trace.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) the libgit2 contributors. All rights reserved.
+ *
+ * This file is part of libgit2, distributed under the GNU GPL v2 with
+ * a Linking Exception. For full terms see the included COPYING file.
+ */
+
+#include "buffer.h"
+#include "common.h"
+#include "global.h"
+#include "trace.h"
+#include "git2/trace.h"
+
+#ifdef GIT_TRACE
+
+struct git_trace_data git_trace__data = {0};
+
+#endif
+
+int git_trace_set(git_trace_level_t level, git_trace_callback callback)
+{
+#ifdef GIT_TRACE
+ assert(level == 0 || callback != NULL);
+
+ git_trace__data.level = level;
+ git_trace__data.callback = callback;
+ GIT_MEMORY_BARRIER;
+
+ return 0;
+#else
+ GIT_UNUSED(level);
+ GIT_UNUSED(callback);
+
+ giterr_set(GITERR_INVALID,
+ "This version of libgit2 was not built with tracing.");
+ return -1;
+#endif
+}
+