@aglyn/shared-util-logger 1.0.0-beta.143

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # @aglyn/shared-util-logger
2
+
3
+ ---
4
+
5
+ # Logger Helper
6
+
7
+ This library was generated with [Nx](https://nx.dev).
8
+
9
+ Logger framework and logical flow is inspired by `@firebase/logger`
10
+
11
+ This package serves as the base of all logging in the JS SDK. Any logging that is intended to be
12
+ visible to Firebase end developers should go through this module.
13
+
14
+ ## Basic Usage
15
+
16
+ Firebase components should import the `Logger` class and instantiate a new instance by passing a
17
+ component name (
18
+ e.g. `@aglyn/<project-name>`) to the constructor.
19
+
20
+ _e.g._
21
+
22
+ ```typescript
23
+ import { Logger } from '@aglyn/shared-util-logger'
24
+
25
+ const logger = new Logger(`@aglyn/<project-name>`)
26
+ ```
27
+
28
+ Each `Logger` instance supports 5 log functions each to be used in a specific instance:
29
+
30
+ - `debug`: Internal logs; use this to allow developers to send us their debug logs for us to be able
31
+ to diagnose an issue.
32
+ - `log`: Use to inform your user about things they may need to know.
33
+ - `info`: Use if you have to inform the user about something that they need to take a concrete
34
+ action on. Once they take that action, the log should go away.
35
+ - `warn`: Use when a product feature may stop functioning correctly; unexpected scenario.
36
+ - `error`: Only use when user App would stop functioning correctly - super rare!
37
+
38
+ ## Log Format
39
+
40
+ Each log will be formatted in the following manner:
41
+
42
+ ```typescript
43
+ `"[${new Date()}] ${COMPONENT_NAME}: ${...args}"`
44
+ ```
45
+
46
+ ## Running unit tests
47
+
48
+ Run `nx test shared-util-logger` to execute the unit tests via [Jest](https://jestjs.io).
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@aglyn/shared-util-logger",
3
+ "version": "1.0.0-beta.143",
4
+ "license": "Apache-2.0",
5
+ "homepage": "https://aglyn.com",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/aglyn/aglyn.git",
9
+ "directory": "libs/shared/util/logger"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public",
13
+ "provenance": true
14
+ },
15
+ "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./src/index.d.ts",
19
+ "default": "./src/index.js"
20
+ },
21
+ "./*": {
22
+ "types": "./src/lib/*.d.ts",
23
+ "default": "./src/lib/*.js"
24
+ },
25
+ "./package.json": "./package.json"
26
+ },
27
+ "dependencies": {
28
+ "@swc/helpers": "0.5.23"
29
+ },
30
+ "sideEffects": false,
31
+ "types": "./src/index.d.ts",
32
+ "module": "./src/index.js",
33
+ "main": "./src/index.js"
34
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export * from './lib/logger';
package/src/index.js ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ export * from "./lib/logger.js";
17
+
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../libs/shared/util/logger/src/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2021 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './lib/logger'\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,cAAc,kBAAc"}
@@ -0,0 +1,170 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * A container for all of the Logger instances
19
+ */
20
+ export declare const instances: Logger[];
21
+ /**
22
+ * The JS SDK supports 5 log levels and also allows a user the ability to
23
+ * silence the logs altogether.
24
+ *
25
+ * The order is a follows:
26
+ * DEBUG < VERBOSE < INFO < WARN < ERROR
27
+ *
28
+ * All of the log types above the current log level will be captured (i.e. if
29
+ * you set the log level to `INFO`, errors will still be logged, but `DEBUG` and
30
+ * `VERBOSE` logs will not)
31
+ */
32
+ export declare enum LogLevel {
33
+ DEBUG = "debug",
34
+ ERROR = "error",
35
+ INFO = "info",
36
+ SILENT = "silent",
37
+ VERBOSE = "verbose",
38
+ WARN = "warn"
39
+ }
40
+ export type LogLevelString = LogLevel | keyof Console;
41
+ /**
42
+ * We allow users the ability to pass their own log handler. We will pass the
43
+ * type of log, the current log level, and any other arguments passed (i.e. the
44
+ * messages that the user wants to log) to this function.
45
+ */
46
+ export type LogHandler = (loggerInstance: Logger, level: LogLevelString, ...args: unknown[]) => void;
47
+ export interface LogOptions {
48
+ level: LogLevel | keyof Console;
49
+ }
50
+ export interface LogCallbackParams {
51
+ level: LogLevel | keyof Console;
52
+ message: string;
53
+ args: unknown[];
54
+ type: string;
55
+ }
56
+ export type LogCallback = (callbackParams: LogCallbackParams) => void;
57
+ /**
58
+ * By default, `console.debug` is not displayed in the developer console (in
59
+ * chrome). To avoid forcing users to have to opt-in to these logs twice
60
+ * (i.e. once for firebase, and once in the console), we are sending `DEBUG`
61
+ * logs to the `console.log` function.
62
+ */
63
+ export declare const ConsoleMethodKey: Partial<Record<string, string>>;
64
+ /**
65
+ * The default log handler will forward DEBUG, VERBOSE, INFO, WARN, and ERROR
66
+ * messages on to their corresponding console counterparts (if the log method
67
+ * is supported by the current log level)
68
+ *
69
+ * ## The level was decorative (AGL-1151)
70
+ *
71
+ * This handler used to test only the level of the CALL — dropping the literal
72
+ * `'silent'` and forwarding everything else — so `_logLevel` decided nothing
73
+ * and `logger.debug()` reached `console.log` at every level including the
74
+ * default INFO. On a published tenant page that is not a stray line: plugin
75
+ * registration walks every component and preset through `lifecycleEvent`,
76
+ * which logs a before and an after for each, so a visitor's browser formatted
77
+ * and retained ~400 `console.log` calls of internal event names and payloads
78
+ * before the page was interactive — measurably, and on a customer's site.
79
+ *
80
+ * The threshold is now the INSTANCE's, which is what the level's own docblock
81
+ * has always said it means.
82
+ */
83
+ export declare const defaultLogHandler: LogHandler;
84
+ export declare const FALLBACK_LOG_LEVEL = LogLevel.INFO;
85
+ /**
86
+ * TODO: INTEGRATE PACKAGE`debug`
87
+ */
88
+ export declare class Logger {
89
+ name?: string;
90
+ /**
91
+ * The default log level.
92
+ *
93
+ * DEBUG outside production, so a developer keeps the running commentary the
94
+ * handler used to emit unconditionally, and a deployed build does not.
95
+ * Nothing in the workspace calls `setLogLevel`, so this constant is the only
96
+ * threshold that applies anywhere until something does.
97
+ *
98
+ * `process` is guarded because this library is reachable from a browser
99
+ * realm that has no bundler substituting `process.env` — a marketplace
100
+ * plugin bundle. Dot notation is load-bearing: the substitution is textual
101
+ * and never sees the bracket form.
102
+ */
103
+ static defaultLogLevel: LogLevel;
104
+ _logLevel: LogLevelString;
105
+ _logHandler: LogHandler;
106
+ _userLogHandler: LogHandler | null;
107
+ /**
108
+ * The log level of the given Logger instance.
109
+ */
110
+ get logLevel(): LogLevelString;
111
+ /**
112
+ * The log level of the given Logger instance.
113
+ */
114
+ set logLevel(val: LogLevelString);
115
+ /**
116
+ * The main (internal) log handler for the Logger instance.
117
+ * Can be set to a new function in internal package code but not by user.
118
+ */
119
+ get logHandler(): LogHandler;
120
+ /**
121
+ * The main (internal) log handler for the Logger instance.
122
+ * Can be set to a new function in internal package code but not by user.
123
+ */
124
+ set logHandler(val: LogHandler);
125
+ /**
126
+ * The optional, additional, user-defined log handler for the Logger instance.
127
+ */
128
+ get userLogHandler(): LogHandler | null;
129
+ /**
130
+ * The optional, additional, user-defined log handler for the Logger instance.
131
+ */
132
+ set userLogHandler(val: LogHandler | null);
133
+ /**
134
+ * Gives you an instance of a Logger to capture messages according to
135
+ * Firebase's logging scheme.
136
+ *
137
+ * @param name The name that the logs will be associated with
138
+ */
139
+ constructor(name?: string);
140
+ /**
141
+ * Workaround for setter/getter having to be the same type
142
+ */
143
+ setLogLevel(val?: LogLevelString): this;
144
+ /**
145
+ * Set the log level for all logger instances
146
+ */
147
+ static setLogLevel(val?: LogLevelString): typeof Logger;
148
+ /**
149
+ * The optional, additional, user-defined log handler for the Logger instance.
150
+ */
151
+ setUserLogHandler(logCallback: LogCallback | null, options?: LogOptions): void;
152
+ /**
153
+ * The optional, additional, user-defined log handler for the Logger instance.
154
+ */
155
+ static setUserLogHandler(logCallback: LogCallback | null, options?: LogOptions): void;
156
+ /**
157
+ * The functions below are all based on the `console` interface
158
+ */
159
+ /** {@inheritDoc Console.debug} */
160
+ debug(...args: unknown[]): void;
161
+ /** {@inheritDoc Console.log} */
162
+ log(...args: unknown[]): void;
163
+ /** {@inheritDoc Console.info} */
164
+ info(...args: unknown[]): void;
165
+ /** {@inheritDoc Console.warn} */
166
+ warn(...args: unknown[]): void;
167
+ /** {@inheritDoc Console.error} */
168
+ error(...args: unknown[]): void;
169
+ }
170
+ export default Logger;
@@ -0,0 +1,274 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ /**
17
+ * A container for all of the Logger instances
18
+ */ export const instances = [];
19
+ /**
20
+ * The JS SDK supports 5 log levels and also allows a user the ability to
21
+ * silence the logs altogether.
22
+ *
23
+ * The order is a follows:
24
+ * DEBUG < VERBOSE < INFO < WARN < ERROR
25
+ *
26
+ * All of the log types above the current log level will be captured (i.e. if
27
+ * you set the log level to `INFO`, errors will still be logged, but `DEBUG` and
28
+ * `VERBOSE` logs will not)
29
+ */ export var LogLevel = /*#__PURE__*/ function(LogLevel) {
30
+ LogLevel["DEBUG"] = "debug";
31
+ LogLevel["ERROR"] = "error";
32
+ LogLevel["INFO"] = "info";
33
+ LogLevel["SILENT"] = "silent";
34
+ LogLevel["VERBOSE"] = "verbose";
35
+ LogLevel["WARN"] = "warn";
36
+ return LogLevel;
37
+ }({});
38
+ /**
39
+ * By default, `console.debug` is not displayed in the developer console (in
40
+ * chrome). To avoid forcing users to have to opt-in to these logs twice
41
+ * (i.e. once for firebase, and once in the console), we are sending `DEBUG`
42
+ * logs to the `console.log` function.
43
+ */ export const ConsoleMethodKey = {
44
+ ["debug"]: 'log',
45
+ ["verbose"]: 'log',
46
+ ["info"]: 'info',
47
+ ["warn"]: 'warn',
48
+ ["error"]: 'error'
49
+ };
50
+ /**
51
+ * Rank of each level, so "at or above the configured level" is comparable.
52
+ *
53
+ * The levels are string values, so `level >= instance.logLevel` compares them
54
+ * alphabetically — under which `'debug' >= 'error'` holds and `'warn' >= 'info'`
55
+ * does not. A level needs a number to be ordered by.
56
+ *
57
+ * SILENT sits above ERROR: it is the level at which nothing qualifies.
58
+ */ const LOG_LEVEL_RANK = {
59
+ ["debug"]: 0,
60
+ ["verbose"]: 1,
61
+ ["info"]: 2,
62
+ ["warn"]: 3,
63
+ ["error"]: 4,
64
+ ["silent"]: 5
65
+ };
66
+ /**
67
+ * Whether a message at `level` clears the `configured` threshold.
68
+ *
69
+ * `setLogLevel` accepts any `keyof Console`, not just a `LogLevel`, so either
70
+ * side can be a string this table has no rank for. An unranked THRESHOLD falls
71
+ * back to the default one rather than admitting everything; an unranked
72
+ * MESSAGE is passed through to the invalid-logType throw below, which is what
73
+ * names the mistake.
74
+ */ function meetsLogLevel(level, configured) {
75
+ var _LOG_LEVEL_RANK_configured;
76
+ const messageRank = LOG_LEVEL_RANK[level];
77
+ if (messageRank === undefined) return true;
78
+ const threshold = (_LOG_LEVEL_RANK_configured = LOG_LEVEL_RANK[configured]) != null ? _LOG_LEVEL_RANK_configured : LOG_LEVEL_RANK[FALLBACK_LOG_LEVEL];
79
+ return messageRank >= threshold;
80
+ }
81
+ /**
82
+ * The default log handler will forward DEBUG, VERBOSE, INFO, WARN, and ERROR
83
+ * messages on to their corresponding console counterparts (if the log method
84
+ * is supported by the current log level)
85
+ *
86
+ * ## The level was decorative (AGL-1151)
87
+ *
88
+ * This handler used to test only the level of the CALL — dropping the literal
89
+ * `'silent'` and forwarding everything else — so `_logLevel` decided nothing
90
+ * and `logger.debug()` reached `console.log` at every level including the
91
+ * default INFO. On a published tenant page that is not a stray line: plugin
92
+ * registration walks every component and preset through `lifecycleEvent`,
93
+ * which logs a before and an after for each, so a visitor's browser formatted
94
+ * and retained ~400 `console.log` calls of internal event names and payloads
95
+ * before the page was interactive — measurably, and on a customer's site.
96
+ *
97
+ * The threshold is now the INSTANCE's, which is what the level's own docblock
98
+ * has always said it means.
99
+ */ export const defaultLogHandler = (instance, level, ...args)=>{
100
+ if (!level || level === 'silent') return;
101
+ if (!meetsLogLevel(level, instance.logLevel)) return;
102
+ const now = new Date().toISOString();
103
+ const method = ConsoleMethodKey[level];
104
+ if (method) {
105
+ return console[method](`[${now}] ${instance.name}`, ...args);
106
+ }
107
+ throw new Error(`Attempted to log a message with an invalid logType (value: ${level})`);
108
+ };
109
+ export const FALLBACK_LOG_LEVEL = "info";
110
+ /**
111
+ * Whether this build is something other than a deployed one.
112
+ *
113
+ * Proven, never assumed: the default is the QUIET level, and only a readable
114
+ * `NODE_ENV` that is positively not `production` raises it. A bundler that
115
+ * does not substitute the expression, or a realm-plugin bundle with no
116
+ * `process` at all, leaves this false and the deployed behaviour stands —
117
+ * which is the direction a wrong answer here has to fail in.
118
+ *
119
+ * Dot notation on both reads is load-bearing: the substitution is textual and
120
+ * matches only this exact form.
121
+ */ const DEVELOPMENT_RUNTIME = typeof process !== 'undefined' && typeof process.env !== 'undefined' && typeof process.env.NODE_ENV === 'string' && process.env.NODE_ENV !== 'production';
122
+ /**
123
+ * TODO: INTEGRATE PACKAGE`debug`
124
+ */ export class Logger {
125
+ /**
126
+ * The log level of the given Logger instance.
127
+ */ get logLevel() {
128
+ return this._logLevel;
129
+ }
130
+ /**
131
+ * The log level of the given Logger instance.
132
+ */ set logLevel(val) {
133
+ if (!(val in LogLevel)) {
134
+ throw new TypeError(`Invalid value "${val}" assigned to \`logLevel\``);
135
+ }
136
+ this._logLevel = val;
137
+ }
138
+ /**
139
+ * The main (internal) log handler for the Logger instance.
140
+ * Can be set to a new function in internal package code but not by user.
141
+ */ get logHandler() {
142
+ return this._logHandler;
143
+ }
144
+ /**
145
+ * The main (internal) log handler for the Logger instance.
146
+ * Can be set to a new function in internal package code but not by user.
147
+ */ set logHandler(val) {
148
+ if (typeof val !== 'function') {
149
+ throw new TypeError('Value assigned to `logHandler` must be a function');
150
+ }
151
+ this._logHandler = val;
152
+ }
153
+ /**
154
+ * The optional, additional, user-defined log handler for the Logger instance.
155
+ */ get userLogHandler() {
156
+ return this._userLogHandler;
157
+ }
158
+ /**
159
+ * The optional, additional, user-defined log handler for the Logger instance.
160
+ */ set userLogHandler(val) {
161
+ this._userLogHandler = val;
162
+ }
163
+ /**
164
+ * Workaround for setter/getter having to be the same type
165
+ */ setLogLevel(val) {
166
+ if (val && LogLevel[LogLevel[val]] || console[val]) this._logLevel = val;
167
+ else this._logLevel = FALLBACK_LOG_LEVEL;
168
+ return this;
169
+ }
170
+ /**
171
+ * Set the log level for all logger instances
172
+ */ static setLogLevel(val) {
173
+ instances.forEach((inst)=>inst.setLogLevel(val));
174
+ return this;
175
+ }
176
+ /**
177
+ * The optional, additional, user-defined log handler for the Logger instance.
178
+ */ setUserLogHandler(logCallback, options) {
179
+ let customLogLevel = null;
180
+ if ((options == null ? void 0 : options.level) && (LogLevel[LogLevel[options.level]] || console[options.level])) {
181
+ customLogLevel = options.level;
182
+ }
183
+ if (logCallback === null) {
184
+ this.userLogHandler = null;
185
+ } else {
186
+ this.userLogHandler = (instance, level, ...args)=>{
187
+ const message = args.map((arg)=>{
188
+ if (arg == null) {
189
+ return null;
190
+ } else if (typeof arg === 'string') {
191
+ return arg;
192
+ } else if (typeof arg === 'number' || typeof arg === 'boolean') {
193
+ return arg.toString();
194
+ } else if (arg instanceof Error) {
195
+ return arg.message;
196
+ } else {
197
+ try {
198
+ return JSON.stringify(arg);
199
+ } catch (ignored) {
200
+ return null;
201
+ }
202
+ }
203
+ }).filter((arg)=>arg).join(' ');
204
+ if (level >= (customLogLevel != null ? customLogLevel : instance.logLevel)) {
205
+ logCallback({
206
+ args,
207
+ message,
208
+ type: instance.name,
209
+ level: (options == null ? void 0 : options.level) && (LogLevel[LogLevel[options.level]] || console[options.level]) || FALLBACK_LOG_LEVEL
210
+ });
211
+ }
212
+ };
213
+ }
214
+ }
215
+ /**
216
+ * The optional, additional, user-defined log handler for the Logger instance.
217
+ */ static setUserLogHandler(logCallback, options) {
218
+ for (const instance of instances){
219
+ instance.setUserLogHandler(logCallback, options);
220
+ }
221
+ }
222
+ /**
223
+ * The functions below are all based on the `console` interface
224
+ */ /** {@inheritDoc Console.debug} */ debug(...args) {
225
+ this._logHandler(this, "debug", ...args);
226
+ this._userLogHandler && this._userLogHandler(this, "debug", ...args);
227
+ }
228
+ /** {@inheritDoc Console.log} */ log(...args) {
229
+ this._logHandler(this, "verbose", ...args);
230
+ this._userLogHandler && this._userLogHandler(this, "verbose", ...args);
231
+ }
232
+ /** {@inheritDoc Console.info} */ info(...args) {
233
+ this._logHandler(this, "info", ...args);
234
+ this._userLogHandler && this._userLogHandler(this, "info", ...args);
235
+ }
236
+ /** {@inheritDoc Console.warn} */ warn(...args) {
237
+ this._logHandler(this, "warn", ...args);
238
+ this._userLogHandler && this._userLogHandler(this, "warn", ...args);
239
+ }
240
+ /** {@inheritDoc Console.error} */ error(...args) {
241
+ this._logHandler(this, "error", ...args);
242
+ this._userLogHandler && this._userLogHandler(this, "error", ...args);
243
+ }
244
+ /**
245
+ * Gives you an instance of a Logger to capture messages according to
246
+ * Firebase's logging scheme.
247
+ *
248
+ * @param name The name that the logs will be associated with
249
+ */ constructor(name){
250
+ this.name = name;
251
+ this._logLevel = Logger.defaultLogLevel;
252
+ this._logHandler = defaultLogHandler;
253
+ this._userLogHandler = null;
254
+ /**
255
+ * Capture the current instance for later use
256
+ */ instances.push(this);
257
+ }
258
+ }
259
+ /**
260
+ * The default log level.
261
+ *
262
+ * DEBUG outside production, so a developer keeps the running commentary the
263
+ * handler used to emit unconditionally, and a deployed build does not.
264
+ * Nothing in the workspace calls `setLogLevel`, so this constant is the only
265
+ * threshold that applies anywhere until something does.
266
+ *
267
+ * `process` is guarded because this library is reachable from a browser
268
+ * realm that has no bundler substituting `process.env` — a marketplace
269
+ * plugin bundle. Dot notation is load-bearing: the substitution is textual
270
+ * and never sees the bracket form.
271
+ */ Logger.defaultLogLevel = DEVELOPMENT_RUNTIME ? "debug" : "info";
272
+ export default Logger;
273
+
274
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/shared/util/logger/src/lib/logger.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2022 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A container for all of the Logger instances\n */\nexport const instances: Logger[] = []\n\n/**\n * The JS SDK supports 5 log levels and also allows a user the ability to\n * silence the logs altogether.\n *\n * The order is a follows:\n * DEBUG < VERBOSE < INFO < WARN < ERROR\n *\n * All of the log types above the current log level will be captured (i.e. if\n * you set the log level to `INFO`, errors will still be logged, but `DEBUG` and\n * `VERBOSE` logs will not)\n */\nexport enum LogLevel {\n DEBUG = 'debug',\n ERROR = 'error',\n INFO = 'info',\n SILENT = 'silent',\n VERBOSE = 'verbose',\n WARN = 'warn',\n}\n\nexport type LogLevelString = LogLevel | keyof Console\n\n/**\n * We allow users the ability to pass their own log handler. We will pass the\n * type of log, the current log level, and any other arguments passed (i.e. the\n * messages that the user wants to log) to this function.\n */\nexport type LogHandler = (\n loggerInstance: Logger,\n level: LogLevelString,\n ...args: unknown[]\n) => void\n\nexport interface LogOptions {\n level: LogLevel | keyof Console\n}\n\nexport interface LogCallbackParams {\n level: LogLevel | keyof Console\n message: string\n args: unknown[]\n type: string\n}\n\nexport type LogCallback = (callbackParams: LogCallbackParams) => void\n\n/**\n * By default, `console.debug` is not displayed in the developer console (in\n * chrome). To avoid forcing users to have to opt-in to these logs twice\n * (i.e. once for firebase, and once in the console), we are sending `DEBUG`\n * logs to the `console.log` function.\n */\nexport const ConsoleMethodKey: Partial<Record<string, string>> = {\n [LogLevel.DEBUG]: 'log',\n [LogLevel.VERBOSE]: 'log',\n [LogLevel.INFO]: 'info',\n [LogLevel.WARN]: 'warn',\n [LogLevel.ERROR]: 'error',\n}\n\n/**\n * Rank of each level, so \"at or above the configured level\" is comparable.\n *\n * The levels are string values, so `level >= instance.logLevel` compares them\n * alphabetically — under which `'debug' >= 'error'` holds and `'warn' >= 'info'`\n * does not. A level needs a number to be ordered by.\n *\n * SILENT sits above ERROR: it is the level at which nothing qualifies.\n */\nconst LOG_LEVEL_RANK: Record<string, number> = {\n [LogLevel.DEBUG]: 0,\n [LogLevel.VERBOSE]: 1,\n [LogLevel.INFO]: 2,\n [LogLevel.WARN]: 3,\n [LogLevel.ERROR]: 4,\n [LogLevel.SILENT]: 5,\n}\n\n/**\n * Whether a message at `level` clears the `configured` threshold.\n *\n * `setLogLevel` accepts any `keyof Console`, not just a `LogLevel`, so either\n * side can be a string this table has no rank for. An unranked THRESHOLD falls\n * back to the default one rather than admitting everything; an unranked\n * MESSAGE is passed through to the invalid-logType throw below, which is what\n * names the mistake.\n */\nfunction meetsLogLevel(level: LogLevelString, configured: LogLevelString): boolean {\n const messageRank = LOG_LEVEL_RANK[level as string]\n if (messageRank === undefined) return true\n const threshold =\n LOG_LEVEL_RANK[configured as string] ?? LOG_LEVEL_RANK[FALLBACK_LOG_LEVEL]\n return messageRank >= threshold\n}\n\n/**\n * The default log handler will forward DEBUG, VERBOSE, INFO, WARN, and ERROR\n * messages on to their corresponding console counterparts (if the log method\n * is supported by the current log level)\n *\n * ## The level was decorative (AGL-1151)\n *\n * This handler used to test only the level of the CALL — dropping the literal\n * `'silent'` and forwarding everything else — so `_logLevel` decided nothing\n * and `logger.debug()` reached `console.log` at every level including the\n * default INFO. On a published tenant page that is not a stray line: plugin\n * registration walks every component and preset through `lifecycleEvent`,\n * which logs a before and an after for each, so a visitor's browser formatted\n * and retained ~400 `console.log` calls of internal event names and payloads\n * before the page was interactive — measurably, and on a customer's site.\n *\n * The threshold is now the INSTANCE's, which is what the level's own docblock\n * has always said it means.\n */\nexport const defaultLogHandler: LogHandler = (\n instance: Logger,\n level: LogLevelString,\n ...args: any[]\n): void => {\n if (!level || level === 'silent') return\n if (!meetsLogLevel(level, instance.logLevel)) return\n\n const now = new Date().toISOString()\n const method = ConsoleMethodKey[level]\n\n if (method) {\n return (console as unknown as Record<string, (...a: any[]) => void>)[method](`[${now}] ${instance.name}`, ...args)\n }\n\n throw new Error(\n `Attempted to log a message with an invalid logType (value: ${level})`,\n )\n}\n\nexport const FALLBACK_LOG_LEVEL = LogLevel.INFO\n\n/**\n * Whether this build is something other than a deployed one.\n *\n * Proven, never assumed: the default is the QUIET level, and only a readable\n * `NODE_ENV` that is positively not `production` raises it. A bundler that\n * does not substitute the expression, or a realm-plugin bundle with no\n * `process` at all, leaves this false and the deployed behaviour stands —\n * which is the direction a wrong answer here has to fail in.\n *\n * Dot notation on both reads is load-bearing: the substitution is textual and\n * matches only this exact form.\n */\nconst DEVELOPMENT_RUNTIME: boolean =\n typeof process !== 'undefined' &&\n typeof process.env !== 'undefined' &&\n typeof process.env.NODE_ENV === 'string' &&\n process.env.NODE_ENV !== 'production'\n\n/**\n * TODO: INTEGRATE PACKAGE`debug`\n */\nexport class Logger {\n /**\n * The default log level.\n *\n * DEBUG outside production, so a developer keeps the running commentary the\n * handler used to emit unconditionally, and a deployed build does not.\n * Nothing in the workspace calls `setLogLevel`, so this constant is the only\n * threshold that applies anywhere until something does.\n *\n * `process` is guarded because this library is reachable from a browser\n * realm that has no bundler substituting `process.env` — a marketplace\n * plugin bundle. Dot notation is load-bearing: the substitution is textual\n * and never sees the bracket form.\n */\n public static defaultLogLevel: LogLevel = DEVELOPMENT_RUNTIME\n ? LogLevel.DEBUG\n : LogLevel.INFO\n\n _logLevel: LogLevelString = Logger.defaultLogLevel\n _logHandler: LogHandler = defaultLogHandler\n _userLogHandler: LogHandler | null = null\n\n /**\n * The log level of the given Logger instance.\n */\n public get logLevel(): LogLevelString {\n return this._logLevel\n }\n /**\n * The log level of the given Logger instance.\n */\n public set logLevel(val: LogLevelString) {\n if (!(val in LogLevel)) {\n throw new TypeError(`Invalid value \"${val}\" assigned to \\`logLevel\\``)\n }\n this._logLevel = val\n }\n /**\n * The main (internal) log handler for the Logger instance.\n * Can be set to a new function in internal package code but not by user.\n */\n public get logHandler(): LogHandler {\n return this._logHandler\n }\n /**\n * The main (internal) log handler for the Logger instance.\n * Can be set to a new function in internal package code but not by user.\n */\n public set logHandler(val: LogHandler) {\n if (typeof val !== 'function') {\n throw new TypeError('Value assigned to `logHandler` must be a function')\n }\n this._logHandler = val\n }\n /**\n * The optional, additional, user-defined log handler for the Logger instance.\n */\n public get userLogHandler(): LogHandler | null {\n return this._userLogHandler\n }\n /**\n * The optional, additional, user-defined log handler for the Logger instance.\n */\n public set userLogHandler(val: LogHandler | null) {\n this._userLogHandler = val\n }\n\n /**\n * Gives you an instance of a Logger to capture messages according to\n * Firebase's logging scheme.\n *\n * @param name The name that the logs will be associated with\n */\n constructor(public name?: string) {\n /**\n * Capture the current instance for later use\n */\n instances.push(this)\n }\n\n /**\n * Workaround for setter/getter having to be the same type\n */\n public setLogLevel(val?: LogLevelString): this {\n if ((val && (LogLevel as Record<string, unknown>)[(LogLevel as Record<string, unknown>)[val as string] as string]) || (console as unknown as Record<string, unknown>)[val as string])\n this._logLevel = val as LogLevel\n else this._logLevel = FALLBACK_LOG_LEVEL\n return this\n }\n /**\n * Set the log level for all logger instances\n */\n public static setLogLevel(val?: LogLevelString): typeof Logger {\n instances.forEach((inst) => inst.setLogLevel(val))\n return this\n }\n\n /**\n * The optional, additional, user-defined log handler for the Logger instance.\n */\n public setUserLogHandler(\n logCallback: LogCallback | null,\n options?: LogOptions,\n ): void {\n let customLogLevel: LogLevelString | null = null\n if (\n options?.level &&\n ((LogLevel as Record<string, unknown>)[(LogLevel as Record<string, unknown>)[options.level as string] as string] || (console as unknown as Record<string, unknown>)[options.level as string])\n ) {\n customLogLevel = options.level\n }\n if (logCallback === null) {\n this.userLogHandler = null\n } else {\n this.userLogHandler = (\n instance: Logger,\n level: LogLevelString,\n ...args: unknown[]\n ) => {\n const message = args\n .map((arg) => {\n if (arg == null) {\n return null\n } else if (typeof arg === 'string') {\n return arg\n } else if (typeof arg === 'number' || typeof arg === 'boolean') {\n return arg.toString()\n } else if (arg instanceof Error) {\n return arg.message\n } else {\n try {\n return JSON.stringify(arg)\n } catch (ignored) {\n return null\n }\n }\n })\n .filter((arg) => arg)\n .join(' ')\n if (level >= (customLogLevel ?? instance.logLevel)) {\n logCallback({\n args,\n message,\n type: instance.name,\n level:\n (options?.level &&\n ((LogLevel as Record<string, unknown>)[(LogLevel as Record<string, unknown>)[options.level as string] as string] ||\n (console as unknown as Record<string, unknown>)[options.level as string])) as LogLevel ||\n FALLBACK_LOG_LEVEL,\n })\n }\n }\n }\n }\n /**\n * The optional, additional, user-defined log handler for the Logger instance.\n */\n public static setUserLogHandler(\n logCallback: LogCallback | null,\n options?: LogOptions,\n ): void {\n for (const instance of instances) {\n instance.setUserLogHandler(logCallback, options)\n }\n }\n\n /**\n * The functions below are all based on the `console` interface\n */\n\n /** {@inheritDoc Console.debug} */\n public debug(...args: unknown[]): void {\n this._logHandler(this, LogLevel.DEBUG, ...args)\n this._userLogHandler && this._userLogHandler(this, LogLevel.DEBUG, ...args)\n }\n /** {@inheritDoc Console.log} */\n public log(...args: unknown[]): void {\n this._logHandler(this, LogLevel.VERBOSE, ...args)\n this._userLogHandler &&\n this._userLogHandler(this, LogLevel.VERBOSE, ...args)\n }\n /** {@inheritDoc Console.info} */\n public info(...args: unknown[]): void {\n this._logHandler(this, LogLevel.INFO, ...args)\n this._userLogHandler && this._userLogHandler(this, LogLevel.INFO, ...args)\n }\n /** {@inheritDoc Console.warn} */\n public warn(...args: unknown[]): void {\n this._logHandler(this, LogLevel.WARN, ...args)\n this._userLogHandler && this._userLogHandler(this, LogLevel.WARN, ...args)\n }\n /** {@inheritDoc Console.error} */\n public error(...args: unknown[]): void {\n this._logHandler(this, LogLevel.ERROR, ...args)\n this._userLogHandler && this._userLogHandler(this, LogLevel.ERROR, ...args)\n }\n}\n\nexport default Logger\n"],"names":["instances","LogLevel","ConsoleMethodKey","LOG_LEVEL_RANK","meetsLogLevel","level","configured","messageRank","undefined","threshold","FALLBACK_LOG_LEVEL","defaultLogHandler","instance","args","logLevel","now","Date","toISOString","method","console","name","Error","DEVELOPMENT_RUNTIME","process","env","NODE_ENV","Logger","_logLevel","val","TypeError","logHandler","_logHandler","userLogHandler","_userLogHandler","setLogLevel","forEach","inst","setUserLogHandler","logCallback","options","customLogLevel","message","map","arg","toString","JSON","stringify","ignored","filter","join","type","debug","log","info","warn","error","defaultLogLevel","push"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;CAEC,GACD,OAAO,MAAMA,YAAsB,EAAE,CAAA;AAErC;;;;;;;;;;CAUC,GACD,OAAO,IAAA,AAAKC,kCAAAA;;;;;;;WAAAA;MAOX;AA4BD;;;;;CAKC,GACD,OAAO,MAAMC,mBAAoD;IAC/D,SAAgB,EAAE;IAClB,WAAkB,EAAE;IACpB,QAAe,EAAE;IACjB,QAAe,EAAE;IACjB,SAAgB,EAAE;AACpB,EAAC;AAED;;;;;;;;CAQC,GACD,MAAMC,iBAAyC;IAC7C,SAAgB,EAAE;IAClB,WAAkB,EAAE;IACpB,QAAe,EAAE;IACjB,QAAe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