GRPC Core  5.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 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_SUPPORT_LOG_H
20 #define GRPC_SUPPORT_LOG_H
21 
22 #include <inttypes.h>
23 #include <stdarg.h>
24 #include <stdlib.h> /* for abort() */
25 
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
44 typedef enum gpr_log_severity {
49 
50 #define GPR_LOG_VERBOSITY_UNSET -1
51 
53 GPRAPI const char* gpr_log_severity_string(gpr_log_severity severity);
54 
56 #define GPR_DEBUG __FILE__, __LINE__, GPR_LOG_SEVERITY_DEBUG
57 #define GPR_INFO __FILE__, __LINE__, GPR_LOG_SEVERITY_INFO
58 #define GPR_ERROR __FILE__, __LINE__, GPR_LOG_SEVERITY_ERROR
59 
62 GPRAPI void gpr_log(const char* file, int line, gpr_log_severity severity,
63  const char* format, ...) GPR_PRINT_FORMAT_CHECK(4, 5);
64 
65 GPRAPI void gpr_log_message(const char* file, int line,
66  gpr_log_severity severity, const char* message);
67 
69 GPRAPI void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print);
70 
72 
76 typedef struct {
77  const char* file;
78  int line;
80  const char* message;
82 
83 typedef void (*gpr_log_func)(gpr_log_func_args* args);
85 
91 #define GPR_ASSERT(x) \
92  do { \
93  if (!(x)) { \
94  gpr_log(GPR_ERROR, "assertion failed: %s", #x); \
95  abort(); \
96  } \
97  } while (0)
98 
99 #ifdef __cplusplus
100 }
101 #endif
102 
103 #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:46
int line
Definition: log.h:78
Log overrides: applications can use this API to intercept logging calls and use their own implementat...
Definition: log.h:76
#define GPRAPI
Definition: port_platform.h:440
GPRAPI void gpr_set_log_function(gpr_log_func func)
gpr_log_severity
GPR log API.
Definition: log.h:44
const char * message
Definition: log.h:80
const char * file
Definition: log.h:77
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.
void(* gpr_log_func)(gpr_log_func_args *args)
Definition: log.h:83
gpr_log_severity severity
Definition: log.h:79
Definition: log.h:47
#define GPR_PRINT_FORMAT_CHECK(FORMAT_STR, ARGS)
Definition: port_platform.h:424
Definition: log.h:45
GPRAPI void gpr_log_verbosity_init(void)