Skip to content

Commit c16dc86

Browse files
authored
[logger] Adding react-native logger support (#30076)
### Packages impacted by this PR - @azure/logger ### Issues associated with this PR - #30065 ### Describe the problem that is addressed by this PR Adds logging support through the browser implementation of the logger logic. ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary)
1 parent 6d67d3a commit c16dc86

File tree

6 files changed

+48
-32
lines changed

6 files changed

+48
-32
lines changed

sdk/core/logger/src/log-browser.mts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33

4-
export function log(...args: any[]): void {
5-
if (args.length > 0) {
6-
const firstArg = String(args[0]);
7-
if (firstArg.includes(":error")) {
8-
console.error(...args);
9-
} else if (firstArg.includes(":warning")) {
10-
console.warn(...args);
11-
} else if (firstArg.includes(":info")) {
12-
console.info(...args);
13-
} else if (firstArg.includes(":verbose")) {
14-
console.debug(...args);
15-
} else {
16-
console.debug(...args);
17-
}
18-
}
19-
}
4+
export { log } from "./log.common.js";
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
export { log } from "./log.common.js";

sdk/core/logger/src/log.common.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
export function log(...args: any[]): void {
5+
if (args.length > 0) {
6+
const firstArg = String(args[0]);
7+
if (firstArg.includes(":error")) {
8+
console.error(...args);
9+
} else if (firstArg.includes(":warning")) {
10+
console.warn(...args);
11+
} else if (firstArg.includes(":info")) {
12+
console.info(...args);
13+
} else if (firstArg.includes(":verbose")) {
14+
console.debug(...args);
15+
} else {
16+
console.debug(...args);
17+
}
18+
}
19+
}
Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33

4-
export function log(...args: any[]): void {
5-
if (args.length > 0) {
6-
const firstArg = String(args[0]);
7-
if (firstArg.includes(":error")) {
8-
console.error(...args);
9-
} else if (firstArg.includes(":warning")) {
10-
console.warn(...args);
11-
} else if (firstArg.includes(":info")) {
12-
console.info(...args);
13-
} else if (firstArg.includes(":verbose")) {
14-
console.debug(...args);
15-
} else {
16-
console.debug(...args);
17-
}
18-
}
19-
}
4+
export { log } from "./log.common.js";
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
export { log } from "./log.common.js";
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
export function log(...args: any[]): void {
5+
if (args.length > 0) {
6+
const firstArg = String(args[0]);
7+
if (firstArg.includes(":error")) {
8+
console.error(...args);
9+
} else if (firstArg.includes(":warning")) {
10+
console.warn(...args);
11+
} else if (firstArg.includes(":info")) {
12+
console.info(...args);
13+
} else if (firstArg.includes(":verbose")) {
14+
console.debug(...args);
15+
} else {
16+
console.debug(...args);
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)