Sha256: d011f3cea11b968c09122429ffd147b380f5769c535ff5d2428790c843d9c19a

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

/*
 * 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.
 */
#ifndef INCLUDE_trace_h__
#define INCLUDE_trace_h__

#include <git2/trace.h>
#include "buffer.h"

#ifdef GIT_TRACE

struct git_trace_data {
	git_trace_level_t level;
	git_trace_callback callback;
};

extern struct git_trace_data git_trace__data;

GIT_INLINE(void) git_trace__write_fmt(
	git_trace_level_t level,
	const char *fmt, ...)
{
	git_trace_callback callback = git_trace__data.callback;
	git_buf message = GIT_BUF_INIT;
	va_list ap;

	va_start(ap, fmt);
	git_buf_vprintf(&message, fmt, ap);
	va_end(ap);

	callback(level, git_buf_cstr(&message));

	git_buf_free(&message);
}

#define git_trace_level()		(git_trace__data.level)
#define git_trace(l, ...)		{ \
									if (git_trace__data.level >= l && \
										git_trace__data.callback != NULL) { \
										git_trace__write_fmt(l, __VA_ARGS__); \
									} \
								}

#else

#define git_trace_level()		((void)0)
#define git_trace(lvl, ...)		((void)0)

#endif

#endif

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rugged-0.21.4 vendor/libgit2/src/trace.h
rugged-0.21.3 vendor/libgit2/src/trace.h
rugged-0.21.2 vendor/libgit2/src/trace.h
rugged-0.21.0 vendor/libgit2/src/trace.h