• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <grpc/support/port_platform.h>
23 #include <stdarg.h>
24 #include <stdlib.h> /* for abort() */
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 /** The severity of a log message - use the #defines below when calling into
31    grpc_absl_log to additionally supply file and line data */
32 typedef enum gpr_log_severity {
33   GPR_LOG_SEVERITY_DEBUG,
34   GPR_LOG_SEVERITY_INFO,
35   GPR_LOG_SEVERITY_ERROR
36 } gpr_log_severity;
37 
38 /** Macros to build log contexts at various severity levels */
39 #define GPR_DEBUG __FILE__, __LINE__, GPR_LOG_SEVERITY_DEBUG
40 #define GPR_INFO __FILE__, __LINE__, GPR_LOG_SEVERITY_INFO
41 #define GPR_ERROR __FILE__, __LINE__, GPR_LOG_SEVERITY_ERROR
42 
43 /**
44  * EXPERIMENTAL. API stability not guaranteed.
45  * Should only be used from gRPC PHP and RUBY.
46  * This will be removed once Ruby and PHP can start using C++ APIs.
47  * We would replace this with calls to absl LOG functions.
48  * grpc_absl_log is equivalent to
49  * ABSL_LOG(severity) << message_str;
50  * **/
51 GPRAPI void grpc_absl_log(const char* file, int line, gpr_log_severity severity,
52                           const char* message_str);
53 
54 /**
55  * EXPERIMENTAL. API stability not guaranteed.
56  * Should only be used from gRPC PHP and RUBY.
57  * This will be removed once Ruby and PHP can start using C++ APIs.
58  * We would replace this with calls to absl LOG functions.
59  * grpc_absl_log_int is equivalent to
60  * ABSL_LOG(severity) << message_str << num;
61  * **/
62 GPRAPI void grpc_absl_log_int(const char* file, int line,
63                               gpr_log_severity severity,
64                               const char* message_str, intptr_t num);
65 
66 /**
67  * EXPERIMENTAL. API stability not guaranteed.
68  * Should only be used from gRPC PHP and RUBY.
69  * This will be removed once Ruby and PHP can start using C++ APIs.
70  * We would replace this with calls to absl LOG functions.
71  * grpc_absl_log_str is equivalent to
72  * ABSL_LOG(severity) << message_str1 << message_str2;
73  * **/
74 GPRAPI void grpc_absl_log_str(const char* file, int line,
75                               gpr_log_severity severity,
76                               const char* message_str1,
77                               const char* message_str2);
78 
79 GPRAPI void gpr_log_verbosity_init(void);
80 
81 #ifdef __cplusplus
82 }
83 #endif
84 
85 #endif /* GRPC_SUPPORT_LOG_H */
86