GRPC Core  4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
log.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015, Google Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 #ifndef GRPC_SUPPORT_LOG_H
35 #define GRPC_SUPPORT_LOG_H
36 
37 #include <inttypes.h>
38 #include <stdarg.h>
39 #include <stdlib.h> /* for abort() */
40 
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
59 typedef enum gpr_log_severity {
64 
65 #define GPR_LOG_VERBOSITY_UNSET -1
66 
68 GPRAPI const char *gpr_log_severity_string(gpr_log_severity severity);
69 
71 #define GPR_DEBUG __FILE__, __LINE__, GPR_LOG_SEVERITY_DEBUG
72 #define GPR_INFO __FILE__, __LINE__, GPR_LOG_SEVERITY_INFO
73 #define GPR_ERROR __FILE__, __LINE__, GPR_LOG_SEVERITY_ERROR
74 
77 GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity,
78  const char *format, ...) GPR_PRINT_FORMAT_CHECK(4, 5);
79 
80 GPRAPI void gpr_log_message(const char *file, int line,
81  gpr_log_severity severity, const char *message);
82 
84 GPRAPI void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print);
85 
87 
91 typedef struct {
92  const char *file;
93  int line;
95  const char *message;
97 
98 typedef void (*gpr_log_func)(gpr_log_func_args *args);
100 
106 #define GPR_ASSERT(x) \
107  do { \
108  if (!(x)) { \
109  gpr_log(GPR_ERROR, "assertion failed: %s", #x); \
110  abort(); \
111  } \
112  } while (0)
113 
114 #ifdef __cplusplus
115 }
116 #endif
117 
118 #endif /* GRPC_SUPPORT_LOG_H */
GPRAPI void GPRAPI void gpr_log_message(const char *file, int line, gpr_log_severity severity, const char *message)
Definition: log.h:61
int line
Definition: log.h:93
Log overrides: applications can use this API to intercept logging calls and use their own implementat...
Definition: log.h:91
#define GPRAPI
Definition: port_platform.h:416
GPRAPI void gpr_set_log_function(gpr_log_func func)
gpr_log_severity
GPR log API.
Definition: log.h:59
const char * message
Definition: log.h:95
const char * file
Definition: log.h:92
GPRAPI const char * gpr_log_severity_string(gpr_log_severity severity)
Returns a string representation of the log severity.
GPRAPI void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print)
Set global log verbosity.
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
Log a message.
GPRAPI void gpr_log_verbosity_init()
void(* gpr_log_func)(gpr_log_func_args *args)
Definition: log.h:98
gpr_log_severity severity
Definition: log.h:94
Definition: log.h:62
#define GPR_PRINT_FORMAT_CHECK(FORMAT_STR, ARGS)
Definition: port_platform.h:400
Definition: log.h:60