File: clog.h

package info (click to toggle)
pytorch 1.13.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 139,252 kB
  • sloc: cpp: 1,100,274; python: 706,454; ansic: 83,052; asm: 7,618; java: 3,273; sh: 2,841; javascript: 612; makefile: 323; xml: 269; ruby: 185; yacc: 144; objc: 68; lex: 44
file content (100 lines) | stat: -rw-r--r-- 2,823 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#pragma once

#include <stdarg.h>
#include <stdlib.h>
#include <inttypes.h>

#define CLOG_NONE 0
#define CLOG_FATAL 1
#define CLOG_ERROR 2
#define CLOG_WARNING 3
#define CLOG_INFO 4
#define CLOG_DEBUG 5

#ifndef CLOG_VISIBILITY
	#if defined(__ELF__)
		#define CLOG_VISIBILITY __attribute__((__visibility__("internal")))
	#elif defined(__MACH__)
		#define CLOG_VISIBILITY __attribute__((__visibility__("hidden")))
	#else
		#define CLOG_VISIBILITY
	#endif
#endif

#ifndef CLOG_ARGUMENTS_FORMAT
	#if defined(__GNUC__)
		#define CLOG_ARGUMENTS_FORMAT __attribute__((__format__(__printf__, 1, 2)))
	#else
		#define CLOG_ARGUMENTS_FORMAT
	#endif
#endif

#ifdef __cplusplus
extern "C" {
#endif

CLOG_VISIBILITY void clog_vlog_debug(const char* module, const char* format, va_list args);
CLOG_VISIBILITY void clog_vlog_info(const char* module, const char* format, va_list args);
CLOG_VISIBILITY void clog_vlog_warning(const char* module, const char* format, va_list args);
CLOG_VISIBILITY void clog_vlog_error(const char* module, const char* format, va_list args);
CLOG_VISIBILITY void clog_vlog_fatal(const char* module, const char* format, va_list args);

#define CLOG_DEFINE_LOG_DEBUG(log_debug_function_name, module, level) \
	CLOG_ARGUMENTS_FORMAT \
	inline static void log_debug_function_name(const char* format, ...) { \
		if (level >= CLOG_DEBUG) { \
			va_list args; \
			va_start(args, format); \
			clog_vlog_debug(module, format, args); \
			va_end(args); \
		} \
	}

#define CLOG_DEFINE_LOG_INFO(log_info_function_name, module, level) \
	CLOG_ARGUMENTS_FORMAT \
	inline static void log_info_function_name(const char* format, ...) { \
		if (level >= CLOG_INFO) { \
			va_list args; \
			va_start(args, format); \
			clog_vlog_info(module, format, args); \
			va_end(args); \
		} \
	}

#define CLOG_DEFINE_LOG_WARNING(log_warning_function_name, module, level) \
	CLOG_ARGUMENTS_FORMAT \
	inline static void log_warning_function_name(const char* format, ...) { \
		if (level >= CLOG_WARNING) { \
			va_list args; \
			va_start(args, format); \
			clog_vlog_warning(module, format, args); \
			va_end(args); \
		} \
	}

#define CLOG_DEFINE_LOG_ERROR(log_error_function_name, module, level) \
	CLOG_ARGUMENTS_FORMAT \
	inline static void log_error_function_name(const char* format, ...) { \
		if (level >= CLOG_ERROR) { \
			va_list args; \
			va_start(args, format); \
			clog_vlog_error(module, format, args); \
			va_end(args); \
		} \
	}

#define CLOG_DEFINE_LOG_FATAL(log_fatal_function_name, module, level) \
	CLOG_ARGUMENTS_FORMAT \
	inline static void log_fatal_function_name(const char* format, ...) { \
		if (level >= CLOG_FATAL) { \
			va_list args; \
			va_start(args, format); \
			clog_vlog_fatal(module, format, args); \
			va_end(args); \
		} \
		abort(); \
	}

#ifdef __cplusplus
} /* extern "C" */
#endif