You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the target where CLS is needed, import the "@cpp-cls-logging//trpc/logging/cls:cls_log_api" dependency. For example:
64
-
```
65
+
66
+
```bzl
65
67
cc_binary(
66
68
name="helloworld_server",
67
69
srcs= ["helloworld_server.cc"],
@@ -79,6 +81,7 @@ Not supported yet.
79
81
## Plugin Configuration
80
82
81
83
To use the Etcd plugin, you must add the plugin configuration to the framework configuration file:
84
+
82
85
```yaml
83
86
plugins:
84
87
log:
@@ -110,20 +113,20 @@ The following is a detailed explanation of these configuration items:
110
113
111
114
The CLS plugin provides a plugin registration interface ::trpc::cls::Init(), and users need to call this interface before starting the framework.
112
115
113
-
For server scenarios, users need to call the TrpcApp::RegisterPlugins function in the service startup:
116
+
1.For server scenarios, users need to call the TrpcApp::RegisterPlugins function in the service startup:
114
117
115
-
```cpp
116
-
#include "trpc/logging/cls/cls_log_api.h"
118
+
```cpp
119
+
#include"trpc/logging/cls/cls_log_api.h"
117
120
118
-
class HelloworldServer : public ::trpc::TrpcApp {
119
-
public:
120
-
...
121
-
int RegisterPlugins() override {
122
-
::trpc::logging::cls::Init();
123
-
return 0;
124
-
}
125
-
};
126
-
```
121
+
classHelloworldServer : public ::trpc::TrpcApp {
122
+
public:
123
+
...
124
+
int RegisterPlugins() override {
125
+
::trpc::logging::cls::Init();
126
+
return 0;
127
+
}
128
+
};
129
+
```
127
130
128
131
2. For pure client scenarios, you need to call it after starting the framework configuration initialization and before starting other framework modules:
129
132
@@ -149,6 +152,7 @@ For server scenarios, users need to call the TrpcApp::RegisterPlugins function i
149
152
* Before using the CLS plugin, you need to ensure that the CLS service is correctly activated and configured. In addition, you also need to know how to create log topics and configure log delivery rules on the Tencent Cloud console. The following is a brief introduction to these two aspects:
150
153
151
154
### Activate and configure CLS service
155
+
152
156
1. Log in to the Tencent Cloud Console [TencentCloud](https://cloud.tencent.com/login?s_url=https%3A%2F%2Fconsole.cloud.tencent.com%2F) and find the Cloud Log Service[CLS](https://cloud.tencent.com/product/cls) in the product list.
153
157
154
158
2. In the CLS console, create a new log set.
@@ -158,13 +162,15 @@ For server scenarios, users need to call the TrpcApp::RegisterPlugins function i
158
162
4. In the newly created log topic, configure log delivery rules. You can set the delivery target (e.g., COS, CDN, etc.), delivery frequency, and delivery file format according to your needs.
159
163
160
164
### Get the Topic ID of the log topic
165
+
161
166
1. Log in to the Tencent Cloud Console [TencentCloud](https://cloud.tencent.com/login?s_url=https%3A%2F%2Fconsole.cloud.tencent.com%2F) and find the Cloud Log Service[CLS](https://cloud.tencent.com/product/cls) in the product list.
162
167
163
168
2. Enter the page of the log topic you just created.
164
169
165
170
3. On the basic information page of the log topic, find the Topic ID of the log topic. Add this Topic ID to the plugin configuration to send log data to that topic.
166
171
167
172
### Special Tips
173
+
168
174
1. To ensure that log data can be correctly sent to the CLS platform, please make sure your Tencent Cloud account has sufficient permissions. When using the CLS plugin, you need to configure the SecretId and SecretKey in the yaml file. These two parameters can be created and obtained in the API key management page of the Tencent Cloud Console[TencentCloud](https://cloud.tencent.com/login?s_url=https%3A%2F%2Fconsole.cloud.tencent.com%2F).
169
175
170
176
2. Please note that sending log data to the CLS platform may incur certain costs. For specific cost standards, please refer to the billing instructions in the Tencent Cloud official document [TencentCloud](https://buy.cloud.tencent.com/pricing).
0 commit comments