Skip to content

Commit 6fdbc55

Browse files
committed
fix: optimize console.log
1 parent aff71fa commit 6fdbc55

File tree

6 files changed

+14
-100
lines changed

6 files changed

+14
-100
lines changed

src/modules/apigw/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ class Apigw {
713713
if (curApi.usagePlan.secrets.created === true) {
714714
for (let sIdx = 0; sIdx < secrets.secretIds.length; sIdx++) {
715715
const secretId = secrets.secretIds[sIdx];
716+
console.log(`Removing any previously deployed secret key: ${secretId}`);
716717
await this.removeOrUnbindRequest({
717718
Action: 'DisableApiKey',
718719
accessKeyId: secretId,
@@ -721,7 +722,6 @@ class Apigw {
721722
Action: 'DeleteApiKey',
722723
accessKeyId: secretId,
723724
});
724-
console.log(`Removing any previously deployed secret key. ${secretId}`);
725725
}
726726
}
727727
}
@@ -784,6 +784,7 @@ class Apigw {
784784
serviceId,
785785
environmentName: environment,
786786
});
787+
console.log(`Unrelease service: ${serviceId}, environment: ${environment} success`);
787788

788789
if (created === true) {
789790
// delete service
@@ -792,6 +793,7 @@ class Apigw {
792793
Action: 'DeleteService',
793794
serviceId,
794795
});
796+
console.log(`Remove service: ${serviceId} success`);
795797
}
796798
}
797799
}

src/modules/cns/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,10 @@ class Cns {
188188
const deleteList = inputs.deleteList || [];
189189

190190
if (deleteList.length > 0) {
191-
console.log(
192-
`Deleting records which deployed by this project, but not in this records list. `,
193-
);
191+
console.log(`Removing records which deployed by this project, but not in this records list`);
194192
for (let recordNum = 0; recordNum < deleteList.length; recordNum++) {
195193
console.log(
196-
`Deleting record ${deleteList[recordNum].subDomain} ${deleteList[recordNum].recordId} `,
194+
`Removing record ${deleteList[recordNum].subDomain} ${deleteList[recordNum].recordId} `,
197195
);
198196
const deleteInputs = {
199197
Action: 'RecordDelete',
@@ -210,7 +208,7 @@ class Cns {
210208
console.log(`Error API_CNS_RecordDelete: ${e.message}`);
211209
}
212210
console.log(
213-
`Deleted record ${deleteList[recordNum].subDomain} ${deleteList[recordNum].recordId} `,
211+
`Remove record ${deleteList[recordNum].subDomain} ${deleteList[recordNum].recordId} success`,
214212
);
215213
}
216214
}

src/modules/cos/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class Cos {
171171
}
172172

173173
async deleteTags(inputs = {}) {
174-
console.log(`Deleting tags for ${this.region}'s bucket: ${inputs.bucket} ...`);
174+
console.log(`Removing tags for ${this.region}'s bucket: ${inputs.bucket} ...`);
175175
const deleteTagsHandler = this.promisify(
176176
this.cosClient.deleteBucketTagging.bind(this.cosClient),
177177
);
@@ -221,7 +221,7 @@ class Cos {
221221
}
222222

223223
async deleteCors(inputs = {}) {
224-
console.log(`Deleting cors for ${this.region}'s bucket: ${inputs.bucket} ...`);
224+
console.log(`Removing cors for ${this.region}'s bucket: ${inputs.bucket} ...`);
225225
const deleteCorsHandler = this.promisify(this.cosClient.deleteBucketCors.bind(this.cosClient));
226226
try {
227227
await deleteCorsHandler({
@@ -290,7 +290,7 @@ class Cos {
290290
}
291291

292292
async deleteLifecycle(inputs = {}) {
293-
console.log(`Deleting lifecycle for ${this.region}'s bucket: ${inputs.bucket} ...`);
293+
console.log(`Removing lifecycle for ${this.region}'s bucket: ${inputs.bucket} ...`);
294294
const deleteLifecycle = this.promisify(
295295
this.cosClient.deleteBucketLifecycle.bind(this.cosClient),
296296
);

src/modules/cos/index.test.js

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -48,51 +48,3 @@ class ClientTest {
4848
}
4949

5050
new ClientTest().cosTest();
51-
52-
/* 测试结果:
53-
Getting release domain records ...
54-
Getted release domain.
55-
Doing action about domain records ...
56-
Resolving abc - cname1.dnspod.com
57-
Creating ...
58-
Created (recordId is 562263334)
59-
Modifying status to enable
60-
Modified status to enable
61-
Resolving abc - cname1.dnspod.com
62-
Creating ...
63-
Created (recordId is 562263340)
64-
Modifying status to enable
65-
Modified status to enable
66-
Resolving cde - cname1.dnspod.com
67-
Creating ...
68-
Created (recordId is 562263381)
69-
Modifying status to enable
70-
Modified status to enable
71-
Resolving cde - cname1.dnspod.com
72-
Creating ...
73-
Created (recordId is 562263465)
74-
Modifying status to enable
75-
Modified status to enable
76-
Resolving xyz - cname2.dnspod.com
77-
Creating ...
78-
Created (recordId is 562263473)
79-
Modifying status to enable
80-
Modified status to enable
81-
{"logs":{"records":[{"subDomain":"abc","recordType":"CNAME","recordLine":"移动","recordId":"562263334","value":"cname1.dnspod.com.","status":"enable","domain":"anycodes.cn"},{"subDomain":"abc","recordType":"CNAME","recordLine":"电信","recordId":"562263340","value":"cname1.dnspod.com.","status":"enable","domain":"anycodes.cn"},{"subDomain":"cde","recordType":"CNAME","recordLine":"移动","recordId":"562263381","value":"cname1.dnspod.com.","status":"enable","domain":"anycodes.cn"},{"subDomain":"cde","recordType":"CNAME","recordLine":"电信","recordId":"562263465","value":"cname1.dnspod.com.","status":"enable","domain":"anycodes.cn"},{"subDomain":"xyz","recordType":"CNAME","recordLine":"默认","recordId":"562263473","value":"cname2.dnspod.com.","status":"enable","domain":"anycodes.cn"}]},"error":[]}
82-
{
83-
logs: { records: [ [Object], [Object], [Object], [Object], [Object] ] },
84-
error: []
85-
}
86-
Deleting records which deployed by this project, but not in this records list.
87-
Deleting record abc 562263334
88-
Deleted record abc 562263334
89-
Deleting record abc 562263340
90-
Deleted record abc 562263340
91-
Deleting record cde 562263381
92-
Deleted record cde 562263381
93-
Deleting record cde 562263465
94-
Deleted record cde 562263465
95-
Deleting record xyz 562263473
96-
Deleted record xyz 562263473
97-
{ logs: {}, error: [] }
98-
*/

src/modules/multi-scf/index.test.js

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
const secret = require('../../../../secret');
21
const ScfUtils = require('./index');
32

43
class ClientTest {
54
async scfTest() {
65
const scf = new ScfUtils({
7-
SecretId: secret.SecretId,
8-
SecretKey: secret.SecretKey,
6+
SecretId: '',
7+
SecretKey: '',
98
}, ['ap-shanghai', 'ap-guangzhou']);
109
const scfDemo = {
1110
name: 'myFunctionttest',
@@ -74,40 +73,3 @@ class ClientTest {
7473
}
7574

7675
new ClientTest().scfTest();
77-
78-
/* 测试结果:
79-
Creating funtion myFunction1 in ap-guangzhou ...
80-
Getting function myFunction1's configure ...
81-
Adding tags for funtion myFunction1 in ap-guangzhou ...
82-
Deploying myFunction1's triggers in ap-guangzhou.
83-
Checking function myFunction1 status ...
84-
Modify tags ...
85-
Modified tags.
86-
Checking function myFunction1 status ...
87-
Deploying timer triggers: timer.
88-
Deployed funtion undefined.
89-
{"RequestId":"ea9d3a73-1842-413a-be71-56a7bc385381","ModTime":"2020-03-27 17:12:40","CodeInfo":"","Description":"My Serverless Function","Triggers":[{"Response":{"RequestId":"210e2f21-0ac9-4259-99d3-e2abf4d1b159","TriggerInfo":{"AddTime":"2020-03-27 17:12:44","AvailableStatus":"Available","CustomArgument":"mytest argument","Enable":1,"ModTime":"2020-03-27 17:12:44","TriggerDesc":"{\"cron\":\"0 *6"}","TriggerName":"timer","Type":"timer"}}}],"Handler":"index.main_handler","CodeSize":0,"Timeout":20,"FunctionVersion":"$LATEST","MemorySize":256,"Runtime":"Python3.6","FunctionName":"myFunction1","VpcConfig":{"VpcId":"","SubnetId":""},"UseGpu":"FALSE","Environment":{"Variables":[{"Key":"TEST","Value":"value"}]},"CodeResult":"success","CodeError":"","ErrNo":0,"Namespace":"default","Role":"SCF_PythonLogsRole","InstallDependency":"FALSE","Status":"Creating","StatusDesc":"","ClsLogsetId":"","ClsTopicId":"","FunctionId":"lam-r19fhf72","Tags":[],"EipConfig":{"EipFixed":"FALSE","Eips":[]},"AccessInfo":{"Host":"","Vip":""},"Type":"Event","DeadLetterConfig":{"Type":"","Name":"","FilterType":""},"Layers":[],"L5Enable":"FALSE","AddTime":"2020-03-27 17:12:40","PublicNetConfig":{"PublicNetStatus":"ENABLE","EipConfig":{"EipStatus":"DISABLE","EipAddress":[]}},"OnsEnable":"FALSE"}
90-
{
91-
RequestId: '02ff599b-5720-4dfb-94c0-b3f333868d31',
92-
Result: {
93-
BillDuration: 2,
94-
Duration: 2,
95-
ErrMsg: '',
96-
FunctionRequestId: '02ff599b-5720-4dfb-94c0-b3f333868d31',
97-
InvokeResult: 0,
98-
Log: 'START RequestId: 02ff599b-5720-4dfb-94c0-b3f333868d31\n' +
99-
'Event RequestId: 02ff599b-5720-4dfb-94c0-b3f333868d31\n' +
100-
'{}\n' +
101-
'Received event: {}\n' +
102-
`Received context: {'memory_limit_in_mb': 256, 'time_limit_in_ms': 20000, 'request_id': '02ff599b-5720-4dfb-94c0-b3f333868d31', 'environment': '{"TENCENTCLOUD_SECRETID":"AKIDPH1aD0k43GtL17YuoszTJYKABNa6B8FAddTfay3WoYMb79G9QXSesbSz2yiREMdN","TENCENTCLOUD_SECRETKEY":"LtunGCMtsfkGqQmgDECkHkskse5+WennrMPJbreXE84=","TENCENTCLOUD_SESSIONTOKEN":"26Z03TWGXBrt0b3QHemtqOdM4s6vEMe6d455a7dd94c5e489a1cdea1b1126f5e8-M_KpWmubhn_Xgr0j6ULJItvuEYSCcQGWgWyvW39L8nksAfRnzKx-CsGcYXRTVyq7_SrldrOZwHgYf3lzQKXkt9qJ4tGb50VmLmaCoSWy8D8ggbbeJ4vaj_DRg_QE8ZBm6fMlSdRkKe95MqkN0Sukmj_OVjG_tv6pr-svZiAEsspT6Ga5QwuBecFl7sJOE8GpgmfUQKEa68284ryfMCd0SRZXaP1FfMefozBabrwD28lWLtwh8a7L3vklOhTIFZSL_tyZO1AGMvKasiuGjuvqm7mKQeq5fUaFJkBdblX9hbFLdQZoQ8tLxv2yz0rjiBQGTXrC901kb1NqZqJISQlAVikaqdetDIxnvrq3bI881U","TEST":"value"}', 'environ': 'TEST=value;TENCENTCLOUD_SESSIONTOKEN=26Z03TWGXBrt0b3QHemtqOdM4s6vEMe6d455a7dd94c5e489a1cdea1b1126f5e8-M_KpWmubhn_Xgr0j6ULJItvuEYSCcQGWgWyvW39L8nksAfRnzKx-CsGcYXRTVyq7_SrldrOZwHgYf3lzQKXkt9qJ4tGb50VmLmaCoSWy8D8ggbbeJ4vaj_DRg_QE8ZBm6fMlSdRkKe95MqkN0Sukmj_OVjG_tv6pr-svZiAEsspT6Ga5QwuBecFl7sJOE8GpgmfUQKEa68284ryfMCd0SRZXaP1FfMefozBabrwD28lWLtwh8a7L3vklOhTIFZSL_tyZO1AGMvKasiuGjuvqm7mKQeq5fUaFJkBdblX9hbFLdQZoQ8tLxv2yz0rjiBQGTXrC901kb1NqZqJISQlAVikaqdetDIxnvrq3bI881U;TENCENTCLOUD_SECRETID=AKIDPH1aD0k43GtL17YuoszTJYKABNa6B8FAddTfay3WoYMb79G9QXSesbSz2yiREMdN;TENCENTCLOUD_SECRETKEY=LtunGCMtsfkGqQmgDECkHkskse5+WennrMPJbreXE84=;SCF_NAMESPACE=default', 'function_version': '$LATEST', 'function_name': 'myFunction1', 'namespace': 'default'}\n` +
103-
'Hello world\n' +
104-
'\n' +
105-
'END RequestId: 02ff599b-5720-4dfb-94c0-b3f333868d31\n' +
106-
'Report RequestId: 02ff599b-5720-4dfb-94c0-b3f333868d31 Duration:2ms Memory:256MB MemUsage:11.2188MB',
107-
MemUsage: 11763712,
108-
RetMsg: '"Hello World"'
109-
}
110-
}
111-
Deleteing funtion myFunction1 ...
112-
Removed function and triggers.
113-
*/

src/modules/scf/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class Scf {
191191
// TODO: now apigw can not sync in SCF trigger list
192192
// await this.apigwClient.remove(curTrigger);
193193
} else {
194-
console.log(`Deleting ${curTrigger.Type} triggers: ${curTrigger.TriggerName}.`);
194+
console.log(`Removing ${curTrigger.Type} triggers: ${curTrigger.TriggerName}.`);
195195
const delRes = await this.scfClient.request({
196196
Action: 'DeleteTrigger',
197197
Version: '2018-04-16',
@@ -531,8 +531,8 @@ class Scf {
531531

532532
// 移除函数的主逻辑
533533
async remove(inputs = {}) {
534-
console.log(`Deleting function ${inputs.functionName || inputs.FunctionName} ...`);
535534
const functionName = inputs.functionName || inputs.FunctionName;
535+
console.log(`Removing function ${functionName} ...`);
536536
const namespace = inputs.namespace || inputs.Namespace || CONFIGS.defaultNamespace;
537537

538538
// check function exist, then delete
@@ -564,7 +564,7 @@ class Scf {
564564
}
565565
}
566566

567-
console.log(`Removed function and triggers.`);
567+
console.log(`Remove function ${functionName} and it's triggers success`);
568568
}
569569

570570
async invoke(functionName, inputs = {}) {

0 commit comments

Comments
 (0)