@xh/hoist 76.0.0-SNAPSHOT.1758148932695 → 76.0.0-SNAPSHOT.1758206730608
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/utils/js/LangUtils.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import {PlainObject, Thunkable} from '@xh/hoist/core';
|
|
8
8
|
import {Exception} from '@xh/hoist/core/exception/Exception';
|
|
9
|
-
import {type LogSource
|
|
9
|
+
import {type LogSource} from '@xh/hoist/utils/log';
|
|
10
10
|
import {
|
|
11
11
|
flatMap,
|
|
12
12
|
forOwn,
|
|
@@ -131,7 +131,7 @@ export function throwIf(condition: any, message: unknown) {
|
|
|
131
131
|
*/
|
|
132
132
|
export function warnIf(condition: any, message: any) {
|
|
133
133
|
if (condition) {
|
|
134
|
-
|
|
134
|
+
console.warn(message);
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -140,7 +140,7 @@ export function warnIf(condition: any, message: any) {
|
|
|
140
140
|
*/
|
|
141
141
|
export function errorIf(condition: any, message: any) {
|
|
142
142
|
if (condition) {
|
|
143
|
-
|
|
143
|
+
console.error(message);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
|
|
@@ -170,7 +170,7 @@ export interface APIWarnOptions {
|
|
|
170
170
|
/** An additional message. Can contain suggestions for alternatives. */
|
|
171
171
|
msg?: string;
|
|
172
172
|
|
|
173
|
-
/** Source of message for
|
|
173
|
+
/** Source of message for labeling log message. */
|
|
174
174
|
source?: LogSource;
|
|
175
175
|
}
|
|
176
176
|
|
|
@@ -198,7 +198,7 @@ export function apiDeprecated(name: string, opts: APIWarnOptions = {}) {
|
|
|
198
198
|
msg = opts.msg ?? '',
|
|
199
199
|
warn = `The use of '${name}' has been deprecated and will be removed in ${v}. ${msg}`;
|
|
200
200
|
if (!_seenWarnings[warn]) {
|
|
201
|
-
|
|
201
|
+
console.warn(warn, opts.source);
|
|
202
202
|
_seenWarnings[warn] = true;
|
|
203
203
|
}
|
|
204
204
|
}
|
package/utils/log/LogUtils.ts
CHANGED
|
@@ -36,7 +36,11 @@ export type LogSource = string | {displayName: string} | {constructor: {name: st
|
|
|
36
36
|
* @internal - use public `XH.logLevel`.
|
|
37
37
|
*/
|
|
38
38
|
export function getLogLevel() {
|
|
39
|
-
|
|
39
|
+
try {
|
|
40
|
+
return _logLevel;
|
|
41
|
+
} catch (e) {
|
|
42
|
+
return 'info';
|
|
43
|
+
}
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
/**
|
|
@@ -128,7 +132,9 @@ export function logWarn(msgs: Some<unknown>, source?: LogSource) {
|
|
|
128
132
|
// Implementation
|
|
129
133
|
//----------------------------------
|
|
130
134
|
function loggedDo<T>(messages: Some<unknown>, fn: () => T, source: LogSource, level: LogLevel): T {
|
|
131
|
-
|
|
135
|
+
const _severity: Record<LogLevel, number> = {error: 3, warn: 2, info: 1, debug: 0};
|
|
136
|
+
|
|
137
|
+
if (_severity[level] < _severity[getLogLevel()]) {
|
|
132
138
|
return fn?.();
|
|
133
139
|
}
|
|
134
140
|
|
|
@@ -208,6 +214,5 @@ function parseSource(source: LogSource): string {
|
|
|
208
214
|
// Initialize during parsing to make available immediately.
|
|
209
215
|
//----------------------------------------------------------------
|
|
210
216
|
let _logLevel: LogLevel = 'info';
|
|
211
|
-
const _severity: Record<LogLevel, number> = {error: 3, warn: 2, info: 1, debug: 0};
|
|
212
217
|
|
|
213
218
|
setLogLevel(store.session.get('xhLogLevel', 'info'));
|