1 /* 2 * Copyright (C) the libgit2 contributors. All rights reserved. 3 * 4 * This file is part of libgit2, distributed under the GNU GPL v2 with 5 * a Linking Exception. For full terms see the included COPYING file. 6 */ 7 #ifndef INCLUDE_git_trace_h__ 8 #define INCLUDE_git_trace_h__ 9 10 #include "common.h" 11 #include "types.h" 12 13 /** 14 * @file git2/trace.h 15 * @brief Git tracing configuration routines 16 * @defgroup git_trace Git tracing configuration routines 17 * @ingroup Git 18 * @{ 19 */ 20 GIT_BEGIN_DECL 21 22 /** 23 * Available tracing levels. When tracing is set to a particular level, 24 * callers will be provided tracing at the given level and all lower levels. 25 */ 26 typedef enum { 27 /** No tracing will be performed. */ 28 GIT_TRACE_NONE = 0, 29 30 /** Severe errors that may impact the program's execution */ 31 GIT_TRACE_FATAL = 1, 32 33 /** Errors that do not impact the program's execution */ 34 GIT_TRACE_ERROR = 2, 35 36 /** Warnings that suggest abnormal data */ 37 GIT_TRACE_WARN = 3, 38 39 /** Informational messages about program execution */ 40 GIT_TRACE_INFO = 4, 41 42 /** Detailed data that allows for debugging */ 43 GIT_TRACE_DEBUG = 5, 44 45 /** Exceptionally detailed debugging data */ 46 GIT_TRACE_TRACE = 6 47 } git_trace_level_t; 48 49 /** 50 * An instance for a tracing function 51 */ 52 typedef void GIT_CALLBACK(git_trace_cb)(git_trace_level_t level, const char *msg); 53 54 /** 55 * Sets the system tracing configuration to the specified level with the 56 * specified callback. When system events occur at a level equal to, or 57 * lower than, the given level they will be reported to the given callback. 58 * 59 * @param level Level to set tracing to 60 * @param cb Function to call with trace data 61 * @return 0 or an error code 62 */ 63 GIT_EXTERN(int) git_trace_set(git_trace_level_t level, git_trace_cb cb); 64 65 /** @} */ 66 GIT_END_DECL 67 #endif 68