Skip to content
This repository was archived by the owner on Dec 3, 2024. It is now read-only.

Commit 3589b13

Browse files
use Logger
1 parent 3a5a245 commit 3589b13

File tree

5 files changed

+98
-2
lines changed

5 files changed

+98
-2
lines changed

harmony/checkbox.har

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

harmony/checkbox/src/main/ets/RNCCheckbox.ets

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ import {
2929
ColorSegments,
3030
ViewBaseProps,
3131
} from 'rnoh'
32+
import Logger from './Logger'
3233

3334
export const CHECKBOX_TYPE: string = "RNCCheckbox"
35+
const TAG: string = "[RNOH] RNCCheckbox"
3436

3537
export interface RNCCheckboxProps extends ViewBaseProps {
3638
onCheckColor: ColorSegments
@@ -42,7 +44,6 @@ export interface RNCCheckboxProps extends ViewBaseProps {
4244
strokeColor:ColorSegments
4345
}
4446
export type CheckboxDescriptor = Descriptor<"RNCCheckbox", RNCCheckboxProps>
45-
4647
@Component
4748
export struct RNCCheckbox {
4849
ctx!: RNOHContext
@@ -57,7 +58,7 @@ export struct RNCCheckbox {
5758
this.descriptor = (newDescriptor as CheckboxDescriptor)
5859
}
5960
)
60-
console.info(`RNOH Checkbox ${JSON.stringify(this.descriptor.props)}`)
61+
Logger.debug(TAG, `props ${JSON.stringify(this.descriptor.props)}`)
6162
}
6263

6364
aboutToDisappear() {

lefthook.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# EXAMPLE USAGE:
2+
#
3+
# Refer for explanation to following link:
4+
# https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md
5+
#
6+
# pre-push:
7+
# commands:
8+
# packages-audit:
9+
# tags: frontend security
10+
# run: yarn audit
11+
# gems-audit:
12+
# tags: backend security
13+
# run: bundle audit
14+
#
15+
# pre-commit:
16+
# parallel: true
17+
# commands:
18+
# eslint:
19+
# glob: "*.{js,ts,jsx,tsx}"
20+
# run: yarn eslint {staged_files}
21+
# rubocop:
22+
# tags: backend style
23+
# glob: "*.rb"
24+
# exclude: "application.rb|routes.rb"
25+
# run: bundle exec rubocop --force-exclusion {all_files}
26+
# govet:
27+
# tags: backend style
28+
# files: git ls-files -m
29+
# glob: "*.go"
30+
# run: go vet {files}
31+
# scripts:
32+
# "hello.js":
33+
# runner: node
34+
# "any.go":
35+
# runner: go run
619 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)