Skip to content

Commit 42fb9ce

Browse files
committed
feat: add loggger
1 parent e9eb098 commit 42fb9ce

File tree

4 files changed

+63
-19
lines changed

4 files changed

+63
-19
lines changed

harmony/clip_path/src/main/ets/ClipPath.ets

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { RNComponentContext, RNViewBase, DescriptorWrapper, RNComponentFactory,
22
import {CustomComponentBuilder} from '@rnoh/react-native-openharmony/src/main/ets/RNOH'
33
// import codegen 生成的内容
44
import { RNC } from "@rnoh/react-native-openharmony/generated";
5+
import Logger from "./Logger";
56

67

78
import { TViewBox, IViewPort, TChildrenBuilder } from './types'
@@ -57,6 +58,7 @@ export struct ClipPath {
5758
@State propertyArr: Array<string> = [];
5859

5960
aboutToAppear() {
61+
Logger.info(`${ClipPath.NAME}: aboutToAppear.`);
6062
this.eventEmitter = new RNC.ClipPath.EventEmitter(this.ctx.rnInstance, this.tag)
6163
this.onDescriptorWrapperChange(this.ctx.descriptorRegistry.findDescriptorWrapperByTag<RNC.ClipPath.DescriptorWrapper>(this.tag)!)
6264
this.cleanUpCallbacks.push(this.ctx.descriptorRegistry.subscribeToDescriptorChanges(this.tag,
@@ -66,10 +68,7 @@ export struct ClipPath {
6668
))
6769

6870
const props = this.descriptorWrapper.props
69-
console.log(`FG 1.1 ${JSON.stringify(props)}`)
7071
this.propertyArr = Object.entries(props).map((item: Array<string>) => `${item[0]}: ${item[1]}`)
71-
console.log(`FG 2 ${this.propertyArr}`)
72-
console.log(`FG 3 ${JSON.stringify(this.descriptorWrapper)}`)
7372
}
7473

7574
private onDescriptorWrapperChange(descriptorWrapper: RNC.ClipPath.DescriptorWrapper) {
@@ -78,6 +77,7 @@ export struct ClipPath {
7877
}
7978

8079
aboutToDisappear() {
80+
Logger.info(`${ClipPath.NAME}: aboutToDisappear.`);
8181
this.cleanUpCallbacks.forEach(cb => cb())
8282
}
8383

@@ -220,7 +220,6 @@ export struct ClipPath {
220220
if (rotO === 0 && rotOy === 0) {
221221
val.centerY = scaleConfig.centerY;
222222
}
223-
console.log(`FG rotate ${JSON.stringify(val)}`)
224223
return val
225224
}
226225

@@ -264,7 +263,6 @@ export struct ClipPath {
264263
}
265264
}
266265

267-
console.log(`FG scale ${JSON.stringify(val)}`)
268266
return val
269267
}
270268

harmony/clip_path/src/main/ets/ClipPathCode.ets

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,7 @@ export struct ClipPathCode {
8888
// this.descriptor = (newDescriptor as ClipPathDescriptor)
8989
// }
9090
// )
91-
// console.log(`FG ${JSON.stringify(this)}`)
9291
// this.propertyArr = Object.entries(this).map((item: Array<string>) => `${item[0]}: ${item[1]}`)
93-
// console.log(`FG ${this.propertyArr}`)
94-
// console.log(`FG ${JSON.stringify(this.descriptor)}`)
9592
// }
9693

9794
// aboutToDisappear() {
@@ -244,7 +241,6 @@ export struct ClipPathCode {
244241
if (rotO === 0 && rotOy === 0) {
245242
val.centerY = scaleConfig.centerY;
246243
}
247-
console.log(`FG rotate ${JSON.stringify(val)}`)
248244
return val
249245
}
250246

@@ -295,7 +291,6 @@ export struct ClipPathCode {
295291
}
296292
}
297293

298-
console.log(`FG scale ${JSON.stringify(val)}`)
299294
return val
300295
}
301296

harmony/clip_path/src/main/ets/ClipPathPackage.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,3 @@ export class ClipPathPackage extends RNPackage {
1212
}
1313
}
1414
}
15-
16-
17-
// 根 ts.ts
18-
export * from "./src/main/ets/ClipPathPackage";
19-
20-
// 根 index.ts
21-
export * from "./ts";
22-
export * from './src/main/ets/ClipPath'
23-
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* MIT License
3+
*
4+
* Copyright (C) 2023 Huawei Device Co., Ltd.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
import hilog from '@ohos.hilog';
26+
class Logger
27+
{
28+
private domain : number;
29+
private prefix : string;
30+
private format : string = '%{public}s, %{public}s';
31+
private isDebug : boolean;
32+
/**
33+
* constructor.
34+
* @param Prefix Identifies the log tag.
35+
* @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF.
36+
* */
37+
constructor(prefix
38+
: string = 'MyApp', domain
39+
: number = 0xFF00, isDebug = false)
40+
{
41+
this.prefix = prefix;
42+
this.domain = domain;
43+
this.isDebug = isDebug;
44+
}
45+
debug(... args
46+
: string[]) : void
47+
{
48+
if (this.isDebug)
49+
{
50+
hilog.debug(this.domain, this.prefix, this.format, args);
51+
}
52+
}
53+
info(... args
54+
: string[]) : void { hilog.info(this.domain, this.prefix, this.format, args); }
55+
warn(... args
56+
: string[]) : void { hilog.warn(this.domain, this.prefix, this.format, args); }
57+
error(... args
58+
: string[]) : void { hilog.error(this.domain, this.prefix, this.format, args); }
59+
}
60+
export default new Logger('HarmonyPicker', 0xFF00, true)

0 commit comments

Comments
 (0)